,   CyberForum.ru

- C++


 
C++ http://www.cyberforum.ru/cpp-beginners/thread922510.html
. - C++. , , . . ( ) , . : "AZ", "ZA"( ), ....
C++ 0 . 100, for #include<iostream> #include<conio.h> using namespace std; int main() { int square(int i); int i; for(int i = 0; i<100;i+=2); cout<<i<<square(i)<<endl; getch(); http://www.cyberforum.ru/cpp-beginners/thread922474.html
C++ C++
( ). , catch ( hmeanexcp & excp ) , ? catch ( gmeanexcp & excp ) . #include <iostream> #include <exception> using std :: cout; using std ::...
C++ eofbit
eofbit, if(), while() . - true false?
C++ http://www.cyberforum.ru/cpp-beginners/thread922408.html
? #include <iostream> using namespace std; class A { int PrA1; public: int PuA1;
C++ mem_fun mem_fun_ref ! : " mem_fun() mem_fun_ref() ( 18.4.4.2)." 4 . ? ? , , . , ...

guitarman
0 / 0 / 0
: 13.07.2013
: 10

- C++

13.07.2013, 13:43. 300. 2
( )

. - wxDev-C++. , .
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include <iostream>
#include <iomanip>
 
using namespace std;
 
void mean(const int [], int);
void median(const int [], int);
void mode(const int [], int [], int);
void bubbleSort(int [], int);
void printArray(const int [], int);
 
main()
{
    const int responseSize = 99;
    int frequency[10] = {0},
        response[responseSize] = {6, 7, 8, 9, 8, 7, 8, 9, 8, 9,
                                  7, 8, 9, 5, 9, 8, 7, 8, 7, 8,
                                  6, 7, 8, 9, 3, 9, 8, 7, 8, 7,
                                  7, 8, 9, 8, 9, 8, 9, 7, 8, 9,
                                  6, 7, 8, 7, 8, 7, 9, 8, 9, 2,
                                  7, 8, 9, 8, 9, 8, 9, 7, 5, 3,
                                  5, 6, 7, 2, 5, 3, 9, 4, 6, 4,
                                  7, 8, 9, 6, 8, 7, 8, 9, 7, 8,
                                  7, 4, 4, 2, 5, 3, 8, 7, 5, 6,
                                  4, 5, 6, 1, 6, 5, 7, 8, 7};
    mean(response, responseSize);
    median(response, responseSize);
    mode(frequency, response, responseSize);
    
    return 0;}
 
void mean(const int answer[ ], int arraySize)
{
    int total = 0;
    
    cout << "*********" << endl << " Ñðåä*åå" << endl
         << "*********" << endl;
         
    for (int j = 0; j < arraySize; j++)
        total += answer[j];
        
    cout << "Ñðåä*åå ÿâëÿåòñÿ ñðåä*èì ç**÷å*èåì " << endl
         << "ýëåìå*òîâ ä***ûõ. Ñðåä*åå ç**÷å*èå " << endl
         << "ð*â*î ñóììå ä***ûõ, äåëå**îé ** êîëè÷åñòâî " << endl
         << "ýëåìå*òîâ (" << arraySize <<"). Ñðåä*åå ç**÷å*èå äëÿ" << endl
         << "ä***îãî ð*ñ÷åò* ð*â*î: "
         << total << " / " << arraySize << " = "
         << setiosflags(ios::fixed | ios::showpoint)
         << setprecision(4) << (float) total / arraySize
         << endl << endl;
}
 
void median(const int answer[ ], int size)
{
    cout << endl << "**********" << endl << " Ìåäè***" << endl
         << "**********" << endl
         << "Íåñîðòèðîâ***ûé ì*ññèâ îòâåòîâ";
         
    printArray(answer, size);
    bubbleSort(answer, size);
    cout << endl << endl << "Ñîðòèðîâ***ûé ì*ññèâ îòâåòîâ";
    printArray(answer, size);
    cout << endl << endl << "Ìåäè*** - ýòî ýëåìå*ò " << size / 2
         << " èç ì*ññèâ*" << endl << size << " ñîðòèðîâ***ûõ ýëåìå*òîâ. "
         << endl << "Äëÿ ä***îãî ð*ñ÷åò* ìåäè*** ð*â** "
         << answer[size / 2] << endl << endl;
}
 
void mode(const int freq[ ], int answer[ ], int size)
{
    int largest = 0, modeValue = 0;
    
    cout << endl << "**********" << endl << " Ìîä*" << endl
         << "**********" << endl;
         
    for (int rating = 1; rating <= 9; rating++)
        freq[rating] = 0;
        
    for (int j = 0; j < size; j++)
        ++freq[answer[j]];
    
    cout << "Îòâåò" << setw(11) << "×*ñòîò*"
         << setw(19) << "Ãèñòîãð*ìì*" << endl << endl << setw(54)
         << "1   1   2   2" << endl << setw(54)
         << "5   0   5   0   5" << endl << endl;
         
    for (int rating = 1; rating <= 9; rating++) {
        cout << setw(8) << rating << setw(11)
             << freq[rating] << "                ";
             
        if (freq[rating] > largest) {
            largest = freq[rating];
            modeValue = rating;
        }
    for (int h = 1; h <= freq[rating]; h++)
        cout << '*';
    
    cout << endl;
    }
    
    cout << "Ìîä* - **èáîëåå ÷*ñòî âñòðå÷*þùååñÿ ç**÷å*èå." << endl
         << "Äëÿ ë***îãî ð*ñ÷åò* ìîä* ð*â** " << modeValue
         << ", ýòî ÷èñëî âñòðå÷*åòñÿ " << largest << "  ð*ç."
         << endl;
}
void bubbleSort(int a[ ], int size)
{
    int hold;
    
    for (int pass = 1; pass < size; pass++)
    
        for (int j = 0; j < size - 1; j++)
            
            if (a[j] > a[j + 1]) {
                hold = a[j];
                a[j] = a[j + 1];
                a[j + 1] = hold;
            }
}
 
void printArray(const int a[ ], int size)
{
    for (int j = 0; j < size; j++) {
        
        if (j % 20 == 0)
            cout << endl;
            
        cout << setw(2) << a[j]; 
    }
}
? .
 
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
@Mail.ru