0 / 0 / 0
Регистрация: 08.06.2021
Сообщений: 9
1

Надо упростить код

11.05.2022, 12:10. Показов 849. Ответов 14

Author24 — интернет-сервис помощи студентам
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
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
 
using namespace std;
 
int main() {
    setlocale(LC_ALL, "rus");
    const int N = 25;
    int x, y, k, dgt;
    char A[N][N], c, z;
    string s, a, b, name1, name2;
    a = "НОЛИКИ";
    b = "КРЕСТИКИ";
    z = '0';
    c = 'X';
    cout << "Игра крестики-нолики:" << endl;
    cout << "За кого ходит первый игрок?(введите цифру):" << endl;
    cout << "0: 1" << endl;
    cout << "X: 2" << endl;
    cout << "Цифра: ";
    cin >> dgt;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            A[i][j] = '.';
            cout << A[i][j] << " ";
        }
        cout << endl;
    }
    for (int i = 0; i < 625; i++)
    {
        if ((!(i % 2)) && (dgt == 1)) s = a;
        if ((!(i % 2)) && (dgt == 2)) s = b;
        if ((i % 2) && (dgt == 1)) s = b;
        if ((i % 2) && (dgt == 2)) s = a;
    mylabel:
        cout << "Сделайте ваш ход (" << s << ")" << endl;
        cout << "Строка: ";
        cin >> x;
        cout << "Столбец: ";
        cin >> y;
        x--;
        y--;
        if (A[x][y] != '.')
        {
            system("cls");
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    cout << A[i][j] << " ";
                }
                cout << endl;
            }
            cout << "Данная позиция занята!" << endl;
            goto mylabel;
        }
        if ((!(i % 2)) && (dgt == 1)) A[x][y] = z;
        if ((!(i % 2)) && (dgt == 2)) A[x][y] = c;
        if ((i % 2) && (dgt == 1)) A[x][y] = c;
        if ((i % 2) && (dgt == 2)) A[x][y] = z;
        system("cls");
        k = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                cout << A[i][j] << " ";
            }
            cout << endl;
        }
 
 
 
            k++;
            cout << "Игра закончена! ";
            if ((A[x][y] == z) && (dgt == 1)) cout << " Выиграли 0!" << endl;
            if ((A[x][y] == c) && (dgt == 2)) cout << " Выиграли X!" << endl;
            if ((A[x][y] == c) && (dgt == 1)) cout << " Выиграли 0!" << endl;
            if ((A[x][y] == z) && (dgt == 2)) cout << " Выиграли X!" << endl;
            break;
        }
    }
    if (!(k)) cout << "Игра закончилась вничью!" << endl;
    system("pause");
    return 0;
}
Надо упростить все предпологаемые сюжеты, или хотябы найти быстрый способ написания этой фигни. Я ее еще не закончил, но код рабочий. А если поможете впихнуть туда классы то буду по гроб обязан
0
Лучшие ответы (1)
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
11.05.2022, 12:10
Ответы с готовыми решениями:

можно ли упростить этот код ,код не мой просто нужно чтобы он был проще)
#include &lt;iostream&gt; #include &lt;cmath&gt; #include &lt;string&gt; #include &lt;cstdlib&gt; #include &lt;ctime&gt;...

Надо упростить программу
Program zadnie1; Uses GraphABC; Type funI=function(x:real):real; Function Fx(x:real):real;...

Надо упростить функцию в Jquery
&lt;div class=&quot;hideCont&quot;&gt; &lt;div id=&quot;zg1&quot; class=&quot;headline&quot;...

Пожалуйста упростить ее надо, задача по строкам, завтра сдать нужно
УСЛОВИЕ: Текст записан 60-символьными строками, содержит знаки корректуры: $ – сделать красную...

14
0 / 0 / 0
Регистрация: 08.06.2021
Сообщений: 9
11.05.2022, 12:14  [ТС] 2
Надо упростить вот это
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
(((A[0][0] == '0') && (A[0][1] == '0') && (A[0][2] == '0') && (A[0][3] == '0') && (A[0][4] == '0')) ||
            ((A[0][1] == '0') && (A[0][2] == '0') && (A[0][3] == '0') && (A[0][4] == '0') && (A[0][5] == '0')) ||
            ((A[0][2] == '0') && (A[0][3] == '0') && (A[0][4] == '0') && (A[0][5] == '0') && (A[0][6] == '0')) ||
            ((A[0][3] == '0') && (A[0][4] == '0') && (A[0][5] == '0') && (A[0][6] == '0') && (A[0][7] == '0')) ||
            ((A[0][4] == '0') && (A[0][5] == '0') && (A[0][6] == '0') && (A[0][7] == '0') && (A[0][8] == '0')) ||
            ((A[0][5] == '0') && (A[0][6] == '0') && (A[0][7] == '0') && (A[0][8] == '0') && (A[0][9] == '0')) ||
            ((A[0][6] == '0') && (A[0][7] == '0') && (A[0][8] == '0') && (A[0][9] == '0') && (A[0][10] == '0')) ||
            ((A[0][7] == '0') && (A[0][8] == '0') && (A[0][9] == '0') && (A[0][10] == '0') && (A[0][11] == '0')) ||
            ((A[0][8] == '0') && (A[0][9] == '0') && (A[0][10] == '0') && (A[0][11] == '0') && (A[0][12] == '0')) ||
            ((A[0][9] == '0') && (A[0][10] == '0') && (A[0][11] == '0') && (A[0][12] == '0') && (A[0][13] == '0')) ||
            ((A[0][10] == '0') && (A[0][11] == '0') && (A[0][12] == '0') && (A[0][13] == '0') && (A[0][14] == '0')) ||
            ((A[0][11] == '0') && (A[0][12] == '0') && (A[0][13] == '0') && (A[0][14] == '0') && (A[0][15] == '0')) ||
            ((A[0][12] == '0') && (A[0][13] == '0') && (A[0][14] == '0') && (A[0][15] == '0') && (A[0][16] == '0')) ||
            ((A[0][13] == '0') && (A[0][14] == '0') && (A[0][15] == '0') && (A[0][16] == '0') && (A[0][17] == '0')) ||
            ((A[0][14] == '0') && (A[0][15] == '0') && (A[0][16] == '0') && (A[0][17] == '0') && (A[0][18] == '0')) ||
            ((A[0][15] == '0') && (A[0][16] == '0') && (A[0][17] == '0') && (A[0][18] == '0') && (A[0][19] == '0')) ||
            ((A[0][16] == '0') && (A[0][17] == '0') && (A[0][18] == '0') && (A[0][19] == '0') && (A[0][20] == '0')) ||
            ((A[0][17] == '0') && (A[0][18] == '0') && (A[0][19] == '0') && (A[0][20] == '0') && (A[0][21] == '0')) ||
            ((A[0][18] == '0') && (A[0][19] == '0') && (A[0][20] == '0') && (A[0][21] == '0') && (A[0][22] == '0')) ||
            ((A[0][19] == '0') && (A[0][20] == '0') && (A[0][21] == '0') && (A[0][22] == '0') && (A[0][23] == '0')) ||
            ((A[0][20] == '0') && (A[0][21] == '0') && (A[0][22] == '0') && (A[0][23] == '0') && (A[0][24] == '0')) ||
 
            ((A[1][0] == '0') && (A[1][1] == '0') && (A[1][2] == '0') && (A[1][3] == '0') && (A[1][4] == '0')) ||
            ((A[1][1] == '0') && (A[1][2] == '0') && (A[1][3] == '0') && (A[1][4] == '0') && (A[1][5] == '0')) ||
            ((A[1][2] == '0') && (A[1][3] == '0') && (A[1][4] == '0') && (A[1][5] == '0') && (A[1][6] == '0')) ||
            ((A[1][3] == '0') && (A[1][4] == '0') && (A[1][5] == '0') && (A[1][6] == '0') && (A[1][7] == '0')) ||
            ((A[1][4] == '0') && (A[1][5] == '0') && (A[1][6] == '0') && (A[1][7] == '0') && (A[1][8] == '0')) ||
            ((A[1][5] == '0') && (A[1][6] == '0') && (A[1][7] == '0') && (A[1][8] == '0') && (A[1][9] == '0')) ||
            ((A[1][6] == '0') && (A[1][7] == '0') && (A[1][8] == '0') && (A[1][9] == '0') && (A[1][10] == '0')) ||
            ((A[1][7] == '0') && (A[1][8] == '0') && (A[1][9] == '0') && (A[1][10] == '0') && (A[1][11] == '0')) ||
            ((A[1][8] == '0') && (A[1][9] == '0') && (A[1][10] == '0') && (A[1][11] == '0') && (A[1][12] == '0')) ||
            ((A[1][9] == '0') && (A[1][10] == '0') && (A[1][11] == '0') && (A[1][12] == '0') && (A[1][13] == '0')) ||
            ((A[1][10] == '0') && (A[1][11] == '0') && (A[1][12] == '0') && (A[1][13] == '0') && (A[1][14] == '0')) ||
            ((A[1][11] == '0') && (A[1][12] == '0') && (A[1][13] == '0') && (A[1][14] == '0') && (A[1][15] == '0')) ||
            ((A[1][12] == '0') && (A[1][13] == '0') && (A[1][14] == '0') && (A[1][15] == '0') && (A[1][16] == '0')) ||
            ((A[1][13] == '0') && (A[1][14] == '0') && (A[1][15] == '0') && (A[1][16] == '0') && (A[1][17] == '0')) ||
            ((A[1][14] == '0') && (A[1][15] == '0') && (A[1][16] == '0') && (A[1][17] == '0') && (A[1][18] == '0')) ||
            ((A[1][15] == '0') && (A[1][16] == '0') && (A[1][17] == '0') && (A[1][18] == '0') && (A[1][19] == '0')) ||
            ((A[1][16] == '0') && (A[1][17] == '0') && (A[1][18] == '0') && (A[1][19] == '0') && (A[1][20] == '0')) ||
            ((A[1][17] == '0') && (A[1][18] == '0') && (A[1][19] == '0') && (A[1][20] == '0') && (A[1][21] == '0')) ||
            ((A[1][18] == '0') && (A[1][19] == '0') && (A[1][20] == '0') && (A[1][21] == '0') && (A[1][22] == '0')) ||
            ((A[1][19] == '0') && (A[1][20] == '0') && (A[1][21] == '0') && (A[1][22] == '0') && (A[1][23] == '0')) ||
            ((A[1][20] == '0') && (A[1][21] == '0') && (A[1][22] == '0') && (A[1][23] == '0') && (A[1][24] == '0')) ||
 
            ((A[2][0] == '0') && (A[2][1] == '0') && (A[2][2] == '0') && (A[2][3] == '0') && (A[2][4] == '0')) ||
            ((A[2][1] == '0') && (A[2][2] == '0') && (A[2][3] == '0') && (A[2][4] == '0') && (A[2][5] == '0')) ||
            ((A[2][2] == '0') && (A[2][3] == '0') && (A[2][4] == '0') && (A[2][5] == '0') && (A[2][6] == '0')) ||
            ((A[2][3] == '0') && (A[2][4] == '0') && (A[2][5] == '0') && (A[2][6] == '0') && (A[2][7] == '0')) ||
            ((A[2][4] == '0') && (A[2][5] == '0') && (A[2][6] == '0') && (A[2][7] == '0') && (A[2][8] == '0')) ||
            ((A[2][5] == '0') && (A[2][6] == '0') && (A[2][7] == '0') && (A[2][8] == '0') && (A[2][9] == '0')) ||
            ((A[2][6] == '0') && (A[2][7] == '0') && (A[2][8] == '0') && (A[2][9] == '0') && (A[2][10] == '0')) ||
            ((A[2][7] == '0') && (A[2][8] == '0') && (A[2][9] == '0') && (A[2][10] == '0') && (A[2][11] == '0')) ||
            ((A[2][8] == '0') && (A[2][9] == '0') && (A[2][10] == '0') && (A[2][11] == '0') && (A[2][12] == '0')) ||
            ((A[2][9] == '0') && (A[2][10] == '0') && (A[2][11] == '0') && (A[2][12] == '0') && (A[2][13] == '0')) ||
            ((A[2][10] == '0') && (A[2][11] == '0') && (A[2][12] == '0') && (A[2][13] == '0') && (A[2][14] == '0')) ||
            ((A[2][11] == '0') && (A[2][12] == '0') && (A[2][13] == '0') && (A[2][14] == '0') && (A[2][15] == '0')) ||
            ((A[2][12] == '0') && (A[2][13] == '0') && (A[2][14] == '0') && (A[2][15] == '0') && (A[2][16] == '0')) ||
            ((A[2][13] == '0') && (A[2][14] == '0') && (A[2][15] == '0') && (A[2][16] == '0') && (A[2][17] == '0')) ||
            ((A[2][14] == '0') && (A[2][15] == '0') && (A[2][16] == '0') && (A[2][17] == '0') && (A[2][18] == '0')) ||
            ((A[2][15] == '0') && (A[2][16] == '0') && (A[2][17] == '0') && (A[2][18] == '0') && (A[2][19] == '0')) ||
            ((A[2][16] == '0') && (A[2][17] == '0') && (A[2][18] == '0') && (A[2][19] == '0') && (A[2][20] == '0')) ||
            ((A[2][17] == '0') && (A[2][18] == '0') && (A[2][19] == '0') && (A[2][20] == '0') && (A[2][21] == '0')) ||
            ((A[2][18] == '0') && (A[2][19] == '0') && (A[2][20] == '0') && (A[2][21] == '0') && (A[2][22] == '0')) ||
            ((A[2][19] == '0') && (A[2][20] == '0') && (A[2][21] == '0') && (A[2][22] == '0') && (A[2][23] == '0')) ||
            ((A[2][20] == '0') && (A[2][21] == '0') && (A[2][22] == '0') && (A[2][23] == '0') && (A[2][24] == '0')) ||
 
            ((A[3][0] == '0') && (A[3][1] == '0') && (A[3][2] == '0') && (A[3][3] == '0') && (A[3][4] == '0')) ||
            ((A[3][1] == '0') && (A[3][2] == '0') && (A[3][3] == '0') && (A[3][4] == '0') && (A[3][5] == '0')) ||
            ((A[3][2] == '0') && (A[3][3] == '0') && (A[3][4] == '0') && (A[3][5] == '0') && (A[3][6] == '0')) ||
            ((A[3][3] == '0') && (A[3][4] == '0') && (A[3][5] == '0') && (A[3][6] == '0') && (A[3][7] == '0')) ||
            ((A[3][4] == '0') && (A[3][5] == '0') && (A[3][6] == '0') && (A[3][7] == '0') && (A[3][8] == '0')) ||
            ((A[3][5] == '0') && (A[3][6] == '0') && (A[3][7] == '0') && (A[3][8] == '0') && (A[3][9] == '0')) ||
            ((A[3][6] == '0') && (A[3][7] == '0') && (A[3][8] == '0') && (A[3][9] == '0') && (A[3][10] == '0')) ||
            ((A[3][7] == '0') && (A[3][8] == '0') && (A[3][9] == '0') && (A[3][10] == '0') && (A[3][11] == '0')) ||
            ((A[3][8] == '0') && (A[3][9] == '0') && (A[3][10] == '0') && (A[3][11] == '0') && (A[3][12] == '0')) ||
            ((A[3][9] == '0') && (A[3][10] == '0') && (A[3][11] == '0') && (A[3][12] == '0') && (A[3][13] == '0')) ||
            ((A[3][10] == '0') && (A[3][11] == '0') && (A[3][12] == '0') && (A[3][13] == '0') && (A[3][14] == '0')) ||
            ((A[3][11] == '0') && (A[3][12] == '0') && (A[3][13] == '0') && (A[3][14] == '0') && (A[3][15] == '0')) ||
            ((A[3][12] == '0') && (A[3][13] == '0') && (A[3][14] == '0') && (A[3][15] == '0') && (A[3][16] == '0')) ||
            ((A[3][13] == '0') && (A[3][14] == '0') && (A[3][15] == '0') && (A[3][16] == '0') && (A[3][17] == '0')) ||
            ((A[3][14] == '0') && (A[3][15] == '0') && (A[3][16] == '0') && (A[3][17] == '0') && (A[3][18] == '0')) ||
            ((A[3][15] == '0') && (A[3][16] == '0') && (A[3][17] == '0') && (A[3][18] == '0') && (A[3][19] == '0')) ||
            ((A[3][16] == '0') && (A[3][17] == '0') && (A[3][18] == '0') && (A[3][19] == '0') && (A[3][20] == '0')) ||
            ((A[3][17] == '0') && (A[3][18] == '0') && (A[3][19] == '0') && (A[3][20] == '0') && (A[3][21] == '0')) ||
            ((A[3][18] == '0') && (A[3][19] == '0') && (A[3][20] == '0') && (A[3][21] == '0') && (A[3][22] == '0')) ||
            ((A[3][19] == '0') && (A[3][20] == '0') && (A[3][21] == '0') && (A[3][22] == '0') && (A[3][23] == '0')) ||
            ((A[3][20] == '0') && (A[3][21] == '0') && (A[3][22] == '0') && (A[3][23] == '0') && (A[3][24] == '0')) ||
 
            ((A[4][0] == '0') && (A[4][1] == '0') && (A[4][2] == '0') && (A[4][3] == '0') && (A[4][4] == '0')) ||
            ((A[4][1] == '0') && (A[4][2] == '0') && (A[4][3] == '0') && (A[4][4] == '0') && (A[4][5] == '0')) ||
            ((A[4][2] == '0') && (A[4][3] == '0') && (A[4][4] == '0') && (A[4][5] == '0') && (A[4][6] == '0')) ||
            ((A[4][3] == '0') && (A[4][4] == '0') && (A[4][5] == '0') && (A[4][6] == '0') && (A[4][7] == '0')) ||
            ((A[4][4] == '0') && (A[4][5] == '0') && (A[4][6] == '0') && (A[4][7] == '0') && (A[4][8] == '0')) ||
            ((A[4][5] == '0') && (A[4][6] == '0') && (A[4][7] == '0') && (A[4][8] == '0') && (A[4][9] == '0')) ||
            ((A[4][6] == '0') && (A[4][7] == '0') && (A[4][8] == '0') && (A[4][9] == '0') && (A[4][10] == '0')) ||
            ((A[4][7] == '0') && (A[4][8] == '0') && (A[4][9] == '0') && (A[4][10] == '0') && (A[4][11] == '0')) ||
            ((A[4][8] == '0') && (A[4][9] == '0') && (A[4][10] == '0') && (A[4][11] == '0') && (A[4][12] == '0')) ||
            ((A[4][9] == '0') && (A[4][10] == '0') && (A[4][11] == '0') && (A[4][12] == '0') && (A[4][13] == '0')) ||
            ((A[4][10] == '0') && (A[4][11] == '0') && (A[4][12] == '0') && (A[4][13] == '0') && (A[4][14] == '0')) ||
            ((A[4][11] == '0') && (A[4][12] == '0') && (A[4][13] == '0') && (A[4][14] == '0') && (A[4][15] == '0')) ||
            ((A[4][12] == '0') && (A[4][13] == '0') && (A[4][14] == '0') && (A[4][15] == '0') && (A[4][16] == '0')) ||
            ((A[4][13] == '0') && (A[4][14] == '0') && (A[4][15] == '0') && (A[4][16] == '0') && (A[4][17] == '0')) ||
            ((A[4][14] == '0') && (A[4][15] == '0') && (A[4][16] == '0') && (A[4][17] == '0') && (A[4][18] == '0')) ||
            ((A[4][15] == '0') && (A[4][16] == '0') && (A[4][17] == '0') && (A[4][18] == '0') && (A[4][19] == '0')) ||
            ((A[4][16] == '0') && (A[4][17] == '0') && (A[4][18] == '0') && (A[4][19] == '0') && (A[4][20] == '0')) ||
            ((A[4][17] == '0') && (A[4][18] == '0') && (A[4][19] == '0') && (A[4][20] == '0') && (A[4][21] == '0')) ||
            ((A[4][18] == '0') && (A[4][19] == '0') && (A[4][20] == '0') && (A[4][21] == '0') && (A[4][22] == '0')) ||
            ((A[4][19] == '0') && (A[4][20] == '0') && (A[4][21] == '0') && (A[4][22] == '0') && (A[4][23] == '0')) ||
            ((A[4][20] == '0') && (A[4][21] == '0') && (A[4][22] == '0') && (A[4][23] == '0') && (A[4][24] == '0')) ||
 
            ((A[5][0] == '0') && (A[5][1] == '0') && (A[5][2] == '0') && (A[5][3] == '0') && (A[5][4] == '0')) ||
            ((A[5][1] == '0') && (A[5][2] == '0') && (A[5][3] == '0') && (A[5][4] == '0') && (A[5][5] == '0')) ||
            ((A[5][2] == '0') && (A[5][3] == '0') && (A[5][4] == '0') && (A[5][5] == '0') && (A[5][6] == '0')) ||
            ((A[5][3] == '0') && (A[5][4] == '0') && (A[5][5] == '0') && (A[5][6] == '0') && (A[5][7] == '0')) ||
            ((A[5][4] == '0') && (A[5][5] == '0') && (A[5][6] == '0') && (A[5][7] == '0') && (A[5][8] == '0')) ||
            ((A[5][5] == '0') && (A[5][6] == '0') && (A[5][7] == '0') && (A[5][8] == '0') && (A[5][9] == '0')) ||
            ((A[5][6] == '0') && (A[5][7] == '0') && (A[5][8] == '0') && (A[5][9] == '0') && (A[5][10] == '0')) ||
            ((A[5][7] == '0') && (A[5][8] == '0') && (A[5][9] == '0') && (A[5][10] == '0') && (A[5][11] == '0')) ||
            ((A[5][8] == '0') && (A[5][9] == '0') && (A[5][10] == '0') && (A[5][11] == '0') && (A[5][12] == '0')) ||
            ((A[5][9] == '0') && (A[5][10] == '0') && (A[5][11] == '0') && (A[5][12] == '0') && (A[5][13] == '0')) ||
            ((A[5][10] == '0') && (A[5][11] == '0') && (A[5][12] == '0') && (A[5][13] == '0') && (A[5][14] == '0')) ||
            ((A[5][11] == '0') && (A[5][12] == '0') && (A[5][13] == '0') && (A[5][14] == '0') && (A[5][15] == '0')) ||
            ((A[5][12] == '0') && (A[5][13] == '0') && (A[5][14] == '0') && (A[5][15] == '0') && (A[5][16] == '0')) ||
            ((A[5][13] == '0') && (A[5][14] == '0') && (A[5][15] == '0') && (A[5][16] == '0') && (A[5][17] == '0')) ||
            ((A[5][14] == '0') && (A[5][15] == '0') && (A[5][16] == '0') && (A[5][17] == '0') && (A[5][18] == '0')) ||
            ((A[5][15] == '0') && (A[5][16] == '0') && (A[5][17] == '0') && (A[5][18] == '0') && (A[5][19] == '0')) ||
            ((A[5][16] == '0') && (A[5][17] == '0') && (A[5][18] == '0') && (A[5][19] == '0') && (A[5][20] == '0')) ||
            ((A[5][17] == '0') && (A[5][18] == '0') && (A[5][19] == '0') && (A[5][20] == '0') && (A[5][21] == '0')) ||
            ((A[5][18] == '0') && (A[5][19] == '0') && (A[5][20] == '0') && (A[5][21] == '0') && (A[5][22] == '0')) ||
            ((A[5][19] == '0') && (A[5][20] == '0') && (A[5][21] == '0') && (A[5][22] == '0') && (A[5][23] == '0')) ||
            ((A[5][20] == '0') && (A[5][21] == '0') && (A[5][22] == '0') && (A[5][23] == '0') && (A[5][24] == '0')) ||
 
            ((A[6][0] == '0') && (A[6][1] == '0') && (A[6][2] == '0') && (A[6][3] == '0') && (A[6][4] == '0')) ||
            ((A[6][1] == '0') && (A[6][2] == '0') && (A[6][3] == '0') && (A[6][4] == '0') && (A[6][5] == '0')) ||
            ((A[6][2] == '0') && (A[6][3] == '0') && (A[6][4] == '0') && (A[6][5] == '0') && (A[6][6] == '0')) ||
            ((A[6][3] == '0') && (A[6][4] == '0') && (A[6][5] == '0') && (A[6][6] == '0') && (A[6][7] == '0')) ||
            ((A[6][4] == '0') && (A[6][5] == '0') && (A[6][6] == '0') && (A[6][7] == '0') && (A[6][8] == '0')) ||
            ((A[6][5] == '0') && (A[6][6] == '0') && (A[6][7] == '0') && (A[6][8] == '0') && (A[6][9] == '0')) ||
            ((A[6][6] == '0') && (A[6][7] == '0') && (A[6][8] == '0') && (A[6][9] == '0') && (A[6][10] == '0')) ||
            ((A[6][7] == '0') && (A[6][8] == '0') && (A[6][9] == '0') && (A[6][10] == '0') && (A[6][11] == '0')) ||
            ((A[6][8] == '0') && (A[6][9] == '0') && (A[6][10] == '0') && (A[6][11] == '0') && (A[6][12] == '0')) ||
            ((A[6][9] == '0') && (A[6][10] == '0') && (A[6][11] == '0') && (A[6][12] == '0') && (A[6][13] == '0')) ||
            ((A[6][10] == '0') && (A[6][11] == '0') && (A[6][12] == '0') && (A[6][13] == '0') && (A[6][14] == '0')) ||
            ((A[6][11] == '0') && (A[6][12] == '0') && (A[6][13] == '0') && (A[6][14] == '0') && (A[6][15] == '0')) ||
            ((A[6][12] == '0') && (A[6][13] == '0') && (A[6][14] == '0') && (A[6][15] == '0') && (A[6][16] == '0')) ||
            ((A[6][13] == '0') && (A[6][14] == '0') && (A[6][15] == '0') && (A[6][16] == '0') && (A[6][17] == '0')) ||
            ((A[6][14] == '0') && (A[6][15] == '0') && (A[6][16] == '0') && (A[6][17] == '0') && (A[6][18] == '0')) ||
            ((A[6][15] == '0') && (A[6][16] == '0') && (A[6][17] == '0') && (A[6][18] == '0') && (A[6][19] == '0')) ||
            ((A[6][16] == '0') && (A[6][17] == '0') && (A[6][18] == '0') && (A[6][19] == '0') && (A[6][20] == '0')) ||
            ((A[6][17] == '0') && (A[6][18] == '0') && (A[6][19] == '0') && (A[6][20] == '0') && (A[6][21] == '0')) ||
            ((A[6][18] == '0') && (A[6][19] == '0') && (A[6][20] == '0') && (A[6][21] == '0') && (A[6][22] == '0')) ||
            ((A[6][19] == '0') && (A[6][20] == '0') && (A[6][21] == '0') && (A[6][22] == '0') && (A[6][23] == '0')) ||
            ((A[6][20] == '0') && (A[6][21] == '0') && (A[6][22] == '0') && (A[6][23] == '0') && (A[6][24] == '0')) ||
 
            ((A[7][0] == '0') && (A[7][1] == '0') && (A[7][2] == '0') && (A[7][3] == '0') && (A[7][4] == '0')) ||
            ((A[7][1] == '0') && (A[7][2] == '0') && (A[7][3] == '0') && (A[7][4] == '0') && (A[7][5] == '0')) ||
            ((A[7][2] == '0') && (A[7][3] == '0') && (A[7][4] == '0') && (A[7][5] == '0') && (A[7][6] == '0')) ||
            ((A[7][3] == '0') && (A[7][4] == '0') && (A[7][5] == '0') && (A[7][6] == '0') && (A[7][7] == '0')) ||
            ((A[7][4] == '0') && (A[7][5] == '0') && (A[7][6] == '0') && (A[7][7] == '0') && (A[7][8] == '0')) ||
            ((A[7][5] == '0') && (A[7][6] == '0') && (A[7][7] == '0') && (A[7][8] == '0') && (A[7][9] == '0')) ||
            ((A[7][6] == '0') && (A[7][7] == '0') && (A[7][8] == '0') && (A[7][9] == '0') && (A[7][10] == '0')) ||
            ((A[7][7] == '0') && (A[7][8] == '0') && (A[7][9] == '0') && (A[7][10] == '0') && (A[7][11] == '0')) ||
            ((A[7][8] == '0') && (A[7][9] == '0') && (A[7][10] == '0') && (A[7][11] == '0') && (A[7][12] == '0')) ||
            ((A[7][9] == '0') && (A[7][10] == '0') && (A[7][11] == '0') && (A[7][12] == '0') && (A[7][13] == '0')) ||
            ((A[7][10] == '0') && (A[7][11] == '0') && (A[7][12] == '0') && (A[7][13] == '0') && (A[7][14] == '0')) ||
            ((A[7][11] == '0') && (A[7][12] == '0') && (A[7][13] == '0') && (A[7][14] == '0') && (A[7][15] == '0')) ||
            ((A[7][12] == '0') && (A[7][13] == '0') && (A[7][14] == '0') && (A[7][15] == '0') && (A[7][16] == '0')) ||
            ((A[7][13] == '0') && (A[7][14] == '0') && (A[7][15] == '0') && (A[7][16] == '0') && (A[7][17] == '0')) ||
            ((A[7][14] == '0') && (A[7][15] == '0') && (A[7][16] == '0') && (A[7][17] == '0') && (A[7][18] == '0')) ||
            ((A[7][15] == '0') && (A[7][16] == '0') && (A[7][17] == '0') && (A[7][18] == '0') && (A[7][19] == '0')) ||
            ((A[7][16] == '0') && (A[7][17] == '0') && (A[7][18] == '0') && (A[7][19] == '0') && (A[7][20] == '0')) ||
            ((A[7][17] == '0') && (A[7][18] == '0') && (A[7][19] == '0') && (A[7][20] == '0') && (A[7][21] == '0')) ||
            ((A[7][18] == '0') && (A[7][19] == '0') && (A[7][20] == '0') && (A[7][21] == '0') && (A[7][22] == '0')) ||
            ((A[7][19] == '0') && (A[7][20] == '0') && (A[7][21] == '0') && (A[7][22] == '0') && (A[7][23] == '0')) ||
            ((A[7][20] == '0') && (A[7][21] == '0') && (A[7][22] == '0') && (A[7][23] == '0') && (A[7][24] == '0')) ||
 
            ((A[8][0] == '0') && (A[8][1] == '0') && (A[8][2] == '0') && (A[8][3] == '0') && (A[8][4] == '0')) ||
            ((A[8][1] == '0') && (A[8][2] == '0') && (A[8][3] == '0') && (A[8][4] == '0') && (A[8][5] == '0')) ||
            ((A[8][2] == '0') && (A[8][3] == '0') && (A[8][4] == '0') && (A[8][5] == '0') && (A[8][6] == '0')) ||
            ((A[8][3] == '0') && (A[8][4] == '0') && (A[8][5] == '0') && (A[8][6] == '0') && (A[8][7] == '0')) ||
            ((A[8][4] == '0') && (A[8][5] == '0') && (A[8][6] == '0') && (A[8][7] == '0') && (A[8][8] == '0')) ||
            ((A[8][5] == '0') && (A[8][6] == '0') && (A[8][7] == '0') && (A[8][8] == '0') && (A[8][9] == '0')) ||
            ((A[8][6] == '0') && (A[8][7] == '0') && (A[8][8] == '0') && (A[8][9] == '0') && (A[8][10] == '0')) ||
            ((A[8][7] == '0') && (A[8][8] == '0') && (A[8][9] == '0') && (A[8][10] == '0') && (A[8][11] == '0')) ||
            ((A[8][8] == '0') && (A[8][9] == '0') && (A[8][10] == '0') && (A[8][11] == '0') && (A[8][12] == '0')) ||
            ((A[8][9] == '0') && (A[8][10] == '0') && (A[8][11] == '0') && (A[8][12] == '0') && (A[8][13] == '0')) ||
            ((A[8][10] == '0') && (A[8][11] == '0') && (A[8][12] == '0') && (A[8][13] == '0') && (A[8][14] == '0')) ||
            ((A[8][11] == '0') && (A[8][12] == '0') && (A[8][13] == '0') && (A[8][14] == '0') && (A[8][15] == '0')) ||
            ((A[8][12] == '0') && (A[8][13] == '0') && (A[8][14] == '0') && (A[8][15] == '0') && (A[8][16] == '0')) ||
            ((A[8][13] == '0') && (A[8][14] == '0') && (A[8][15] == '0') && (A[8][16] == '0') && (A[8][17] == '0')) ||
            ((A[8][14] == '0') && (A[8][15] == '0') && (A[8][16] == '0') && (A[8][17] == '0') && (A[8][18] == '0')) ||
            ((A[8][15] == '0') && (A[8][16] == '0') && (A[8][17] == '0') && (A[8][18] == '0') && (A[8][19] == '0')) ||
            ((A[8][16] == '0') && (A[8][17] == '0') && (A[8][18] == '0') && (A[8][19] == '0') && (A[8][20] == '0')) ||
            ((A[8][17] == '0') && (A[8][18] == '0') && (A[8][19] == '0') && (A[8][20] == '0') && (A[8][21] == '0')) ||
            ((A[8][18] == '0') && (A[8][19] == '0') && (A[8][20] == '0') && (A[8][21] == '0') && (A[8][22] == '0')) ||
            ((A[8][19] == '0') && (A[8][20] == '0') && (A[8][21] == '0') && (A[8][22] == '0') && (A[8][23] == '0')) ||
            ((A[8][20] == '0') && (A[8][21] == '0') && (A[8][22] == '0') && (A[8][23] == '0') && (A[8][24] == '0')) ||
 
            ((A[9][0] == '0') && (A[9][1] == '0') && (A[9][2] == '0') && (A[9][3] == '0') && (A[9][4] == '0')) ||
            ((A[9][1] == '0') && (A[9][2] == '0') && (A[9][3] == '0') && (A[9][4] == '0') && (A[9][5] == '0')) ||
            ((A[9][2] == '0') && (A[9][3] == '0') && (A[9][4] == '0') && (A[9][5] == '0') && (A[9][6] == '0')) ||
            ((A[9][3] == '0') && (A[9][4] == '0') && (A[9][5] == '0') && (A[9][6] == '0') && (A[9][7] == '0')) ||
            ((A[9][4] == '0') && (A[9][5] == '0') && (A[9][6] == '0') && (A[9][7] == '0') && (A[9][8] == '0')) ||
            ((A[9][5] == '0') && (A[9][6] == '0') && (A[9][7] == '0') && (A[9][8] == '0') && (A[9][9] == '0')) ||
            ((A[9][6] == '0') && (A[9][7] == '0') && (A[9][8] == '0') && (A[9][9] == '0') && (A[9][10] == '0')) ||
            ((A[9][7] == '0') && (A[9][8] == '0') && (A[9][9] == '0') && (A[9][10] == '0') && (A[9][11] == '0')) ||
            ((A[9][8] == '0') && (A[9][9] == '0') && (A[9][10] == '0') && (A[9][11] == '0') && (A[9][12] == '0')) ||
            ((A[9][9] == '0') && (A[9][10] == '0') && (A[9][11] == '0') && (A[9][12] == '0') && (A[9][13] == '0')) ||
            ((A[9][10] == '0') && (A[9][11] == '0') && (A[9][12] == '0') && (A[9][13] == '0') && (A[9][14] == '0')) ||
            ((A[9][11] == '0') && (A[9][12] == '0') && (A[9][13] == '0') && (A[9][14] == '0') && (A[9][15] == '0')) ||
            ((A[9][12] == '0') && (A[9][13] == '0') && (A[9][14] == '0') && (A[9][15] == '0') && (A[9][16] == '0')) ||
            ((A[9][13] == '0') && (A[9][14] == '0') && (A[9][15] == '0') && (A[9][16] == '0') && (A[9][17] == '0')) ||
            ((A[9][14] == '0') && (A[9][15] == '0') && (A[9][16] == '0') && (A[9][17] == '0') && (A[9][18] == '0')) ||
            ((A[9][15] == '0') && (A[9][16] == '0') && (A[9][17] == '0') && (A[9][18] == '0') && (A[9][19] == '0')) ||
            ((A[9][16] == '0') && (A[9][17] == '0') && (A[9][18] == '0') && (A[9][19] == '0') && (A[9][20] == '0')) ||
            ((A[9][17] == '0') && (A[9][18] == '0') && (A[9][19] == '0') && (A[9][20] == '0') && (A[9][21] == '0')) ||
            ((A[9][18] == '0') && (A[9][19] == '0') && (A[9][20] == '0') && (A[9][21] == '0') && (A[9][22] == '0')) ||
            ((A[9][19] == '0') && (A[9][20] == '0') && (A[9][21] == '0') && (A[9][22] == '0') && (A[9][23] == '0')) ||
            ((A[9][20] == '0') && (A[9][21] == '0') && (A[9][22] == '0') && (A[9][23] == '0') && (A[9][24] == '0')))
Код даже не поместился, и кстати это даже не 0.2 от кода
0
2273 / 1764 / 741
Регистрация: 27.07.2012
Сообщений: 5,241
11.05.2022, 12:33 3
C++
1
2
3
4
5
6
7
8
9
10
bool result = true;
for (int i = 0; i < n; ++i)
{
    for (int j = 0; j < m; ++j)
    {
        result &= (A[i][j] == '0');
    }
}
 
if (result) { /*...*/ }
1
Just Do It!
3837 / 2283 / 636
Регистрация: 23.09.2014
Сообщений: 7,053
Записей в блоге: 2
11.05.2022, 12:43 4
Лучший ответ Сообщение было отмечено bormant как решение

Решение

Цитата Сообщение от ChellInSunset Посмотреть сообщение
впихнуть туда классы
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
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
 
using namespace std;
 
class Game
{
public:
    Game(){   run(); }
 
private:
    static const int N{25};
    int x, y, k, dgt;
    char A[N][N], c{'X'}, z{'0'};
    string s, a{"НОЛИКИ"}, b{"КРЕСТИКИ"}, name1, name2;
 
    int run()
    {   cout << "Игра крестики-нолики:" << endl;
        cout << "За кого ходит первый игрок?(введите цифру):" << endl;
        cout << "0: 1" << endl;
        cout << "X: 2" << endl;
        cout << "Цифра: ";
        cin >> dgt;
        for (int i = 0; i < N; i++)
        {   for (int j = 0; j < N; j++)
            {   A[i][j] = '.';
                cout << A[i][j] << " ";
            }
            cout << endl;
        }
        for (int i = 0; i < 625; i++)
        {   if ((!(i % 2)) && (dgt == 1)) s = a;
            if ((!(i % 2)) && (dgt == 2)) s = b;
            if ((i % 2) && (dgt == 1)) s = b;
            if ((i % 2) && (dgt == 2)) s = a;
mylabel:
            cout << "Сделайте ваш ход (" << s << ")" << endl;
            cout << "Строка: ";
            cin >> x;
            cout << "Столбец: ";
            cin >> y;
            x--;
            y--;
            if (A[x][y] != '.')
            {   system("cls");
                for (int i = 0; i < N; i++)
                {   for (int j = 0; j < N; j++)
                    {   cout << A[i][j] << " ";
                    }
                    cout << endl;
                }
                cout << "Данная позиция занята!" << endl;
                goto mylabel;
            }
            if ((!(i % 2)) && (dgt == 1)) A[x][y] = z;
            if ((!(i % 2)) && (dgt == 2)) A[x][y] = c;
            if ((i % 2) && (dgt == 1)) A[x][y] = c;
            if ((i % 2) && (dgt == 2)) A[x][y] = z;
            system("cls");
            k = 0;
            for (int i = 0; i < N; i++)
            {   for (int j = 0; j < N; j++)
                {   cout << A[i][j] << " ";
                }
                cout << endl;
            }
 
            k++;
            cout << "Игра закончена! ";
            if ((A[x][y] == z) && (dgt == 1)) cout << " Выиграли 0!" << endl;
            if ((A[x][y] == c) && (dgt == 2)) cout << " Выиграли X!" << endl;
            if ((A[x][y] == c) && (dgt == 1)) cout << " Выиграли 0!" << endl;
            if ((A[x][y] == z) && (dgt == 2)) cout << " Выиграли X!" << endl;
            break;
        }
        if (!(k)) cout << "Игра закончилась вничью!" << endl;
        return 0;
    }
};
 
int main()
{   setlocale(LC_ALL, "rus");
 
    Game game;
 
    system("pause");
}
1
Эксперт .NET
12062 / 8371 / 1280
Регистрация: 21.01.2016
Сообщений: 31,563
11.05.2022, 13:22 5
ChellInSunset, вторую простыню ты сам написал? Ты не заподозрил, что что-то не то делаешь?
1
0 / 0 / 0
Регистрация: 08.06.2021
Сообщений: 9
12.05.2022, 13:42  [ТС] 6
Я просто не знаю как по другому все сюжеты описать

Добавлено через 6 минут
Цитата Сообщение от XLAT Посмотреть сообщение
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
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
 
using namespace std;
 
class Game
{
public:
    Game(){   run(); }
 
private:
    static const int N{25};
    int x, y, k, dgt;
    char A[N][N], c{'X'}, z{'0'};
    string s, a{"НОЛИКИ"}, b{"КРЕСТИКИ"}, name1, name2;
 
    int run()
    {   cout << "Игра крестики-нолики:" << endl;
        cout << "За кого ходит первый игрок?(введите цифру):" << endl;
        cout << "0: 1" << endl;
        cout << "X: 2" << endl;
        cout << "Цифра: ";
        cin >> dgt;
        for (int i = 0; i < N; i++)
        {   for (int j = 0; j < N; j++)
            {   A[i][j] = '.';
                cout << A[i][j] << " ";
            }
            cout << endl;
        }
        for (int i = 0; i < 625; i++)
        {   if ((!(i % 2)) && (dgt == 1)) s = a;
            if ((!(i % 2)) && (dgt == 2)) s = b;
            if ((i % 2) && (dgt == 1)) s = b;
            if ((i % 2) && (dgt == 2)) s = a;
mylabel:
            cout << "Сделайте ваш ход (" << s << ")" << endl;
            cout << "Строка: ";
            cin >> x;
            cout << "Столбец: ";
            cin >> y;
            x--;
            y--;
            if (A[x][y] != '.')
            {   system("cls");
                for (int i = 0; i < N; i++)
                {   for (int j = 0; j < N; j++)
                    {   cout << A[i][j] << " ";
                    }
                    cout << endl;
                }
                cout << "Данная позиция занята!" << endl;
                goto mylabel;
            }
            if ((!(i % 2)) && (dgt == 1)) A[x][y] = z;
            if ((!(i % 2)) && (dgt == 2)) A[x][y] = c;
            if ((i % 2) && (dgt == 1)) A[x][y] = c;
            if ((i % 2) && (dgt == 2)) A[x][y] = z;
            system("cls");
            k = 0;
            for (int i = 0; i < N; i++)
            {   for (int j = 0; j < N; j++)
                {   cout << A[i][j] << " ";
                }
                cout << endl;
            }
 
            k++;
            cout << "Игра закончена! ";
            if ((A[x][y] == z) && (dgt == 1)) cout << " Выиграли 0!" << endl;
            if ((A[x][y] == c) && (dgt == 2)) cout << " Выиграли X!" << endl;
            if ((A[x][y] == c) && (dgt == 1)) cout << " Выиграли 0!" << endl;
            if ((A[x][y] == z) && (dgt == 2)) cout << " Выиграли X!" << endl;
            break;
        }
        if (!(k)) cout << "Игра закончилась вничью!" << endl;
        return 0;
    }
};
 
int main()
{   setlocale(LC_ALL, "rus");
 
    Game game;
 
    system("pause");
}
Я в этом коде должен чтото изменить? там у меня ошибки выводит

Добавлено через 15 минут
Цитата Сообщение от XLAT Посмотреть сообщение
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
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
 
using namespace std;
 
class Game
{
public:
    Game(){   run(); }
 
private:
    static const int N{25};
    int x, y, k, dgt;
    char A[N][N], c{'X'}, z{'0'};
    string s, a{"НОЛИКИ"}, b{"КРЕСТИКИ"}, name1, name2;
 
    int run()
    {   cout << "Игра крестики-нолики:" << endl;
        cout << "За кого ходит первый игрок?(введите цифру):" << endl;
        cout << "0: 1" << endl;
        cout << "X: 2" << endl;
        cout << "Цифра: ";
        cin >> dgt;
        for (int i = 0; i < N; i++)
        {   for (int j = 0; j < N; j++)
            {   A[i][j] = '.';
                cout << A[i][j] << " ";
            }
            cout << endl;
        }
        for (int i = 0; i < 625; i++)
        {   if ((!(i % 2)) && (dgt == 1)) s = a;
            if ((!(i % 2)) && (dgt == 2)) s = b;
            if ((i % 2) && (dgt == 1)) s = b;
            if ((i % 2) && (dgt == 2)) s = a;
mylabel:
            cout << "Сделайте ваш ход (" << s << ")" << endl;
            cout << "Строка: ";
            cin >> x;
            cout << "Столбец: ";
            cin >> y;
            x--;
            y--;
            if (A[x][y] != '.')
            {   system("cls");
                for (int i = 0; i < N; i++)
                {   for (int j = 0; j < N; j++)
                    {   cout << A[i][j] << " ";
                    }
                    cout << endl;
                }
                cout << "Данная позиция занята!" << endl;
                goto mylabel;
            }
            if ((!(i % 2)) && (dgt == 1)) A[x][y] = z;
            if ((!(i % 2)) && (dgt == 2)) A[x][y] = c;
            if ((i % 2) && (dgt == 1)) A[x][y] = c;
            if ((i % 2) && (dgt == 2)) A[x][y] = z;
            system("cls");
            k = 0;
            for (int i = 0; i < N; i++)
            {   for (int j = 0; j < N; j++)
                {   cout << A[i][j] << " ";
                }
                cout << endl;
            }
 
            k++;
            cout << "Игра закончена! ";
            if ((A[x][y] == z) && (dgt == 1)) cout << " Выиграли 0!" << endl;
            if ((A[x][y] == c) && (dgt == 2)) cout << " Выиграли X!" << endl;
            if ((A[x][y] == c) && (dgt == 1)) cout << " Выиграли 0!" << endl;
            if ((A[x][y] == z) && (dgt == 2)) cout << " Выиграли X!" << endl;
            break;
        }
        if (!(k)) cout << "Игра закончилась вничью!" << endl;
        return 0;
    }
};
 
int main()
{   setlocale(LC_ALL, "rus");
 
    Game game;
 
    system("pause");
}
Почему он говорит что я выиграл одним символом? надо чтобы было 5, я пытался исправить но вышло только хуже

Добавлено через 9 минут
Цитата Сообщение от John Prick Посмотреть сообщение
C++
1
2
3
4
5
6
7
8
9
10
bool result = true;
for (int i = 0; i < n; ++i)
{
    for (int j = 0; j < m; ++j)
    {
        result &= (A[i][j] == '0');
    }
}
 
if (result) { /*...*/ }
Что мне вписать в результат? тот огроменный лист в единичном виде без места на карте?
0
2273 / 1764 / 741
Регистрация: 27.07.2012
Сообщений: 5,241
12.05.2022, 13:48 7
Цитата Сообщение от ChellInSunset Посмотреть сообщение
Что мне вписать в результат?
Откуда ж мне знать. Этот код - пример, как заменить ваше полотнище.
0
0 / 0 / 0
Регистрация: 08.06.2021
Сообщений: 9
12.05.2022, 15:05  [ТС] 8
Заподозрил, но делать было нечего
0
случайный прохожий
2920 / 1937 / 606
Регистрация: 20.07.2013
Сообщений: 5,133
12.05.2022, 21:15 9
Я раньше (давно) примерно так же "портянки" писал:
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
 if (PosReturn)
 {
  I = I+1;
  PosReturn = RichEdit1->Lines->Strings[I].Pos("/index.php?uid=");
  ImageFullName = GCD+MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("units")+6, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("units")-8);
  ImageAddress = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("src=")+5, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("src=")-7);
  if (ImageAddress != "")
  {
  NMHTTP2->Get(ImageAddress);
  Hero22->Hint = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("uid=")+4, RichEdit1->Lines->Strings[I].Pos("><img src=")-RichEdit1->Lines->Strings[I].Pos("uid=")-5);
  if (!FileExists(ImageFullName))
    {
      if (RichEdit2->Lines->IndexOf("<h1>The page cannot be found</h1>") < 0)
        {
          IdHTTP1->Get(ImageAddress, picture);
          picture->Position = NULL;
          image->LoadFromStream(picture);
          Hero22->Picture->Assign(image);
          Hero22->Picture->SaveToFile(ImageFullName);
          picture->Position = NULL;
        }
      else
        Hero22->Picture->LoadFromFile(GCD+"0.jpg");
    }
  else
    Hero22->Picture->LoadFromFile(ImageFullName);
  }
 }
 
  Hero23->Picture = NULL;
  Hero23->Hint = "";
 if (PosReturn)
 {
  I = I+1;
  PosReturn = RichEdit1->Lines->Strings[I].Pos("/index.php?uid=");
  ImageFullName = GCD+MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("units")+6, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("units")-8);
  ImageAddress = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("src=")+5, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("src=")-7);
  if (ImageAddress != "")
  {
  NMHTTP2->Get(ImageAddress);
  Hero23->Hint = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("uid=")+4, RichEdit1->Lines->Strings[I].Pos("><img src=")-RichEdit1->Lines->Strings[I].Pos("uid=")-5);
  if (!FileExists(ImageFullName))
    {
      if (RichEdit2->Lines->IndexOf("<h1>The page cannot be found</h1>") < 0)
        {
          IdHTTP1->Get(ImageAddress, picture);
          picture->Position = NULL;
          image->LoadFromStream(picture);
          Hero23->Picture->Assign(image);
          Hero23->Picture->SaveToFile(ImageFullName);
          picture->Position = NULL;
        }
      else
        Hero23->Picture->LoadFromFile(GCD+"0.jpg");
    }
  else
    Hero23->Picture->LoadFromFile(ImageFullName);
  }
 }
 
  Hero24->Picture = NULL;
  Hero24->Hint = "";
 if (PosReturn)
 {
  I = I+1;
  PosReturn = RichEdit1->Lines->Strings[I].Pos("/index.php?uid=");
  ImageFullName = GCD+MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("units")+6, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("units")-8);
  ImageAddress = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("src=")+5, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("src=")-7);
  if (ImageAddress != "")
  {
  NMHTTP2->Get(ImageAddress);
  Hero24->Hint = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("uid=")+4, RichEdit1->Lines->Strings[I].Pos("><img src=")-RichEdit1->Lines->Strings[I].Pos("uid=")-5);
  if (!FileExists(ImageFullName))
    {
      if (RichEdit2->Lines->IndexOf("<h1>The page cannot be found</h1>") < 0)
        {
          IdHTTP1->Get(ImageAddress, picture);
          picture->Position = NULL;
          image->LoadFromStream(picture);
          Hero24->Picture->Assign(image);
          Hero24->Picture->SaveToFile(ImageFullName);
          picture->Position = NULL;
        }
      else
        Hero24->Picture->LoadFromFile(GCD+"0.jpg");
    }
  else
    Hero24->Picture->LoadFromFile(ImageFullName);
  }
 }
 
  Hero25->Picture = NULL;
  Hero25->Hint = "";
 if (PosReturn)
 {
  I = I+1;
  PosReturn = RichEdit1->Lines->Strings[I].Pos("/index.php?uid=");
  ImageFullName = GCD+MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("units")+6, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("units")-8);
  ImageAddress = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("src=")+5, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("src=")-7);
  if (ImageAddress != "")
  {
  NMHTTP2->Get(ImageAddress);
  Hero25->Hint = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("uid=")+4, RichEdit1->Lines->Strings[I].Pos("><img src=")-RichEdit1->Lines->Strings[I].Pos("uid=")-5);
  if (!FileExists(ImageFullName))
    {
      if (RichEdit2->Lines->IndexOf("<h1>The page cannot be found</h1>") < 0)
        {
          IdHTTP1->Get(ImageAddress, picture);
          picture->Position = NULL;
          image->LoadFromStream(picture);
          Hero25->Picture->Assign(image);
          Hero25->Picture->SaveToFile(ImageFullName);
          picture->Position = NULL;
        }
      else
        Hero25->Picture->LoadFromFile(GCD+"0.jpg");
    }
  else
    Hero25->Picture->LoadFromFile(ImageFullName);
  }
 }
 
  Hero26->Picture = NULL;
  Hero26->Hint = "";
  for (I = I+1; I < RichEdit1->Lines->Count; I++)
  {
    PosReturn = RichEdit1->Lines->Strings[I].Pos("/index.php?uid=");
    if (PosReturn) //found!
      break;
  }
  ImageFullName = GCD+MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("units")+6, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("units")-8);
  ImageAddress = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("src=")+5, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("src=")-7);
  if (ImageAddress != "")
  {
  NMHTTP2->Get(ImageAddress);
  Hero26->Hint = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("uid=")+4, RichEdit1->Lines->Strings[I].Pos("><img src=")-RichEdit1->Lines->Strings[I].Pos("uid=")-5);
  if (!FileExists(ImageFullName))
    {
      if (RichEdit2->Lines->IndexOf("<h1>The page cannot be found</h1>") < 0)
        {
          IdHTTP1->Get(ImageAddress, picture);
          picture->Position = NULL;
          image->LoadFromStream(picture);
          Hero26->Picture->Assign(image);
          Hero26->Picture->SaveToFile(ImageFullName);
          picture->Position = NULL;
        }
      else
        Hero26->Picture->LoadFromFile(GCD+"0.jpg");
    }
  else
    Hero26->Picture->LoadFromFile(ImageFullName);
  }
 
  Hero27->Picture = NULL;
  Hero27->Hint = "";
 if (PosReturn)
 {
  I = I+1;
  PosReturn = RichEdit1->Lines->Strings[I].Pos("/index.php?uid=");
  ImageFullName = GCD+MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("units")+6, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("units")-8);
  ImageAddress = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("src=")+5, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("src=")-7);
  if (ImageAddress != "")
  {
  NMHTTP2->Get(ImageAddress);
  Hero27->Hint = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("uid=")+4, RichEdit1->Lines->Strings[I].Pos("><img src=")-RichEdit1->Lines->Strings[I].Pos("uid=")-5);
  if (!FileExists(ImageFullName))
    {
      if (RichEdit2->Lines->IndexOf("<h1>The page cannot be found</h1>") < 0)
        {
          IdHTTP1->Get(ImageAddress, picture);
          picture->Position = NULL;
          image->LoadFromStream(picture);
          Hero27->Picture->Assign(image);
          Hero27->Picture->SaveToFile(ImageFullName);
          picture->Position = NULL;
        }
      else
        Hero27->Picture->LoadFromFile(GCD+"0.jpg");
    }
  else
    Hero27->Picture->LoadFromFile(ImageFullName);
  }
 }
 
  Hero28->Picture = NULL;
  Hero28->Hint = "";
 if (PosReturn)
 {
  I = I+1;
  PosReturn = RichEdit1->Lines->Strings[I].Pos("/index.php?uid=");
  ImageFullName = GCD+MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("units")+6, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("units")-8);
  ImageAddress = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("src=")+5, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("src=")-7);
  if (ImageAddress != "")
  {
  NMHTTP2->Get(ImageAddress);
  Hero28->Hint = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("uid=")+4, RichEdit1->Lines->Strings[I].Pos("><img src=")-RichEdit1->Lines->Strings[I].Pos("uid=")-5);
  if (!FileExists(ImageFullName))
    {
      if (RichEdit2->Lines->IndexOf("<h1>The page cannot be found</h1>") < 0)
        {
          IdHTTP1->Get(ImageAddress, picture);
          picture->Position = NULL;
          image->LoadFromStream(picture);
          Hero28->Picture->Assign(image);
          Hero28->Picture->SaveToFile(ImageFullName);
          picture->Position = NULL;
        }
      else
        Hero28->Picture->LoadFromFile(GCD+"0.jpg");
    }
  else
    Hero28->Picture->LoadFromFile(ImageFullName);
  }
 }
 
  Hero29->Picture = NULL;
  Hero29->Hint = "";
 if (PosReturn)
 {
  I = I+1;
  PosReturn = RichEdit1->Lines->Strings[I].Pos("/index.php?uid=");
  ImageFullName = GCD+MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("units")+6, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("units")-8);
  ImageAddress = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("src=")+5, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("src=")-7);
  if (ImageAddress != "")
  {
  NMHTTP2->Get(ImageAddress);
  Hero29->Hint = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("uid=")+4, RichEdit1->Lines->Strings[I].Pos("><img src=")-RichEdit1->Lines->Strings[I].Pos("uid=")-5);
  if (!FileExists(ImageFullName))
    {
      if (RichEdit2->Lines->IndexOf("<h1>The page cannot be found</h1>") < 0)
        {
          IdHTTP1->Get(ImageAddress, picture);
          picture->Position = NULL;
          image->LoadFromStream(picture);
          Hero29->Picture->Assign(image);
          Hero29->Picture->SaveToFile(ImageFullName);
          picture->Position = NULL;
        }
      else
        Hero29->Picture->LoadFromFile(GCD+"0.jpg");
    }
  else
    Hero29->Picture->LoadFromFile(ImageFullName);
  }
 }
 
  Hero30->Picture = NULL;
  Hero30->Hint = "";
 if (PosReturn)
 {
  I = I+1;
  PosReturn = RichEdit1->Lines->Strings[I].Pos("/index.php?uid=");
  ImageFullName = GCD+MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("units")+6, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("units")-8);
  ImageAddress = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("src=")+5, RichEdit1->Lines->Strings[I].Pos("weight")-RichEdit1->Lines->Strings[I].Pos("src=")-7);
  if (ImageAddress != "")
  {
  NMHTTP2->Get(ImageAddress);
  Hero30->Hint = MidStr(RichEdit1->Lines->Strings[I], RichEdit1->Lines->Strings[I].Pos("uid=")+4, RichEdit1->Lines->Strings[I].Pos("><img src=")-RichEdit1->Lines->Strings[I].Pos("uid=")-5);
  if (!FileExists(ImageFullName))
    {
      if (RichEdit2->Lines->IndexOf("<h1>The page cannot be found</h1>") < 0)
        {
          IdHTTP1->Get(ImageAddress, picture);
          picture->Position = NULL;
          image->LoadFromStream(picture);
          Hero30->Picture->Assign(image);
          Hero30->Picture->SaveToFile(ImageFullName);
          picture->Position = NULL;
        }
      else
        Hero30->Picture->LoadFromFile(GCD+"0.jpg");
    }
  else
    Hero30->Picture->LoadFromFile(ImageFullName);
  }
 }
0
412 / 285 / 59
Регистрация: 09.03.2016
Сообщений: 2,506
13.05.2022, 00:06 10
Бильдер.. что то сетевое?
0
412 / 285 / 59
Регистрация: 09.03.2016
Сообщений: 2,506
13.05.2022, 00:15 11
https://www.cyberforum.ru/atta... 1652390033

Когда то авторегулятор звука писал.
Там своё с++...
С приколами конечно. Но работает.
Вложения
Тип файла: mp4 final_file(8).mp4 (243.4 Кб, 7 просмотров)
0
412 / 285 / 59
Регистрация: 09.03.2016
Сообщений: 2,506
13.05.2022, 00:22 12
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
//     Уровень регулируеться от нуля до минус пятьдесят
 
   float backNoScal=1.0;  float currentVolume = 0;
                    short zTime =0;// <-- Задержка
            const short deley(90); // --- задержка константа
                 //-------------------------
 void TForm3::ZVolume(float xVol, float cutoff, bool cont_){// <-- Функция  регулируем громкость
      // Form1->Label1->Caption=String(cutoff);
      endpointVolume->GetMasterVolumeLevel(&currentVolume);//<---каждую итерацию
 if(cont_)Form1->Label2->Caption=String(cutoff);
 
         if (xVol < cutoff)
             { // < ========= Или поднимать движок (достиг порядка!)
        if(zTime < deley){zTime++; return;}// <-- Задержка поднятия движка (30 было)
         // <-- поднимаем движок
       endpointVolume->SetMasterVolumeLevel(currentVolume+= fabs(currentVolume-1)/500, NULL);
       // fabs(currentVolume-1)/1000 это с низу --- 0.049... с верху --- 0.001
                          return;
                          } else {//<-- если уровень больше заданного
                       //   xVol/= (6.0-fabs(currentVolume/10.0));// Хитрый делитель
if(cont_)Form1->Label1->Caption=String(xVol);
      xVol=xVol - cutoff; // <-- уровень превышения
                    xVol/=4.0;// <--- всё таки надо подбирать для реальной работы
      xVol=-xVol;// <--- изменить знак на минус
float Set_point = (currentVolume+ xVol >= -50.0) ? currentVolume+ xVol : -48.0;// <--- Ограничитель
              // извлекаем уровень звука и отнимаем от него поправку
   if(Set_point < currentVolume-10)Set_point= (currentVolume-10); 
   // хитрый ключ (Не опускать за раз ниже десяти от уроаня)
 
                //-----------------------
   if(Set_point < backNoScal-2){ // <= новая точка ниже старой  Уменьшить громк.
      zTime =(currentVolume < -30.0) ? deley : 0;
// <-- провал ниже -30 задержки нет(устранение провала... это реально тихо !)
         endpointVolume->SetMasterVolumeLevel(Set_point, NULL);// всё со знаком минус (Регулятор)
                            } }
   endpointVolume->GetMasterVolumeLevel(&backNoScal);// запоминаем старое значение
                                    }
  //--------------------------------------------------------------------------
  //--------------------------------------------------------------------------
 
void __fastcall TForm3::Timer1Timer(TObject *Sender)
{ endpointVolume->GetMasterVolumeLevelScalar(&currentVolume);
Form1->CGauge3->Progress=currentVolume*setting::zMaxVal;//< --- extern из блока 3
}   //-------------------------------------------------------------------------
Добавлено через 3 минуты
Хреново, но регулирует...
1
412 / 285 / 59
Регистрация: 09.03.2016
Сообщений: 2,506
13.05.2022, 00:35 13
https://www.cyberforum.ru/atta... 1652391314
Вложения
Тип файла: mp4 final_file(9).mp4 (279.3 Кб, 6 просмотров)
0
случайный прохожий
2920 / 1937 / 606
Регистрация: 20.07.2013
Сообщений: 5,133
13.05.2022, 00:48 14
Наталья8, что-то такое (но давно уже не работает; нормальных скриншотов не осталось и в сети не нашел):

Надо упростить код
1
412 / 285 / 59
Регистрация: 09.03.2016
Сообщений: 2,506
13.05.2022, 00:52 15
Такого не писал.
0
13.05.2022, 00:52
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
13.05.2022, 00:52
Помогаю со студенческими работами здесь

надо получить равнобед.треугольник у меня код есть но там надо изменить что то,я не могу понять что
Вот по такому примеру надо нарисовать равнобедренный треугольник на турбо си ...

Есть код, надо сделать так, чтобы я мог указать путь файлу, который будет установлен на рабочий. И это все надо сделать в формах
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;...

Надо написать код программы (код есть оформить в маткад не могу_
Видео файл меньше весит чем картинка :D Вот этот код If r1=X0 then g4(r1)=... Как его записать...

Упростить код
С клавиатуры в лист вводится последовательность чисел. Конец ввода 0. Найти сумму элементов листа...

Упростить код
Здравствуйте, преподаватель сказал упросить код заменив сканер но не сказав как именно, а так же...

Упростить код
Есть список a = и индекс 4, надо развернуть список с индекса Так или как-то иначе? a

Упростить код
Нужно сделать максимально простым. Черно-белым.


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
15
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru