Форум программистов, компьютерный форум, киберфорум
C для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.83/6: Рейтинг темы: голосов - 6, средняя оценка - 4.83
0 / 0 / 0
Регистрация: 17.05.2011
Сообщений: 3
1

Найти и исправить ошибки в коде

19.05.2011, 21:54. Показов 1061. Ответов 4
Метки нет (Все метки)

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
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
278
279
280
281
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <time.h>
struct stadiums{
char Name [15] ;
short int D_cr;
int Sapacity;
short int C_pl;
char N_sp [10] [15] ;
};
stadiums s [100] ;
int Count,strok;
void save () {
FILE* f;
if (f==fopen ("C: \\Student\\05IS\\db. kp","w") ==NULL) {
printf ("File coldn't create");
getch ();
return;
}
fwrite (&s,sizeof (s),1,f);
fclose (f);
}
void alf () {
stadiums temp;
for (int i=0; i<Count-1; i++)
for (int j=i+1; j<Count; j++)
if ( (strcmp (strupr (s [j]. Name),strupr (s [i]. Name)) <0) || (strcmp (s [i]. Name,"") ==0)) {
temp=s [j] ;
s [j] =s [i] ;
s [i] =temp;
}
return;
}
void prin_head () {
printf ("-----------------------------------------------------------------------------\n");
printf ("| | Name | Year stadium | Capacity | Amount | Sports |\n");
printf ("-----------------------------------------------------------------------------\n");
return;
}
void prin (int i) {
char pr=' ';
printf ("|%2d |", i+1); strok++;
printf ("%15s |",s [i]. Name);
printf ("%12d |",s [i]. D_cr);
printf ("%8d |",s [i]. Sapacity);
printf ("%6d |",s [i]. C_pl);
for (int j=0; j<s [i]. C_pl; j++) {
if (j==0) printf ("%15s |\n",s [i]. N_sp [j]);
else if (strok! =44) {
printf ("|%2c |%15c |%12c |%8c |%6c |%15s |\n",pr,pr,pr,pr,pr,s [i]. N_sp [j]);
strok++;
}
else{printf ("Press any key for continue"); getch (); clrscr (); strok=0; }
}
printf ("-----------------------------------------------------------------------------\n");
strok++;
return;
}
void prin_all () {
clrscr ();
prin_head ();
strok=3;
for (int i=0; i<Count; i++) {
prin (i);
}
printf ("\n");
return;
}
void add () {
tm *T; time_t tt; tt=time (NULL); T=localtime (&tt);
Count++;
clrscr ();
printf ("\n\t\t\t\tADD RECORD\n");
printf ("Enter Name stadium (no more 15 symbols): ");
scanf ("%s",s [Count-1]. Name);
strupr (s [Count-1]. Name);
do {
printf ("Enter Date of construction: ");
scanf ("%d",&s [Count-1]. D_cr);
}while ( (s [Count-1]. D_cr<1) || (s [Count-1]. D_cr> (T->tm_year+1900)));
do {
printf ("Enter sapacity of stadium: ");
scanf ("%d",&s [Count-1]. Sapacity);
}while (s [Count-1]. Sapacity<1);
do {
printf ("Enter Amount platforms (no more 10): ");
scanf ("%d",&s [Count-1]. C_pl);
} while (s [Count-1]. C_pl<1||s [Count-1]. C_pl>10);
for (int i=0; i<s [Count-1]. C_pl; i++) {
printf ("Enter sport%d (no more 15 symbols): ", i+1);
scanf ("%s",s [Count-1]. N_sp [i]);
strupr (s [Count-1]. N_sp [i]);
}
alf ();
printf ("New record is added\n"); getch ();
return;
}
void remov () {
int num=0;
clrscr ();
printf ("\n\t\t\t\tREMOVE RECORD\n");
prin_all ();
while (num<1||num>Count) {
printf ("Enter number record for edit: ");
scanf ("%d",&num);
}
printf ("You have chosen record: \n");
prin_head ();
prin (num-1);
printf ("Do you want remove record? (Y\\N) \n");
if ( (getch () =='y') || (getch () =='Y')) {
strcpy (s [num-1]. Name,'\0');
s [num-1]. D_cr=0;
s [num-1]. Sapacity=0;
for (int i=0; i<s [num-1]. C_pl; i++)
strcpy (s [num-1]. N_sp [i],'\0');
s [num-1]. C_pl=0;
alf ();
Count--;
printf ("Record is removed\n"); getch ();
}
return;
}
void edit () {
tm *T; time_t tt; tt=time (NULL); T=localtime (&tt);
stadiums temp;
int num=0, i;
clrscr ();
printf ("\t\t\tEDIT RECORD\n");
prin_all ();
while (num<1||num>Count) {
printf ("Enter number record for edit: ");
scanf ("%d",&num);
}
clrscr ();
printf ("You have chosen record: \n");
prin_head ();
prin (num-1);
printf ("Enter new Name stadium (no more 15 symbols): ");
scanf ("%s",temp. Name);
strupr (temp. Name);
do {
printf ("Enter new Date of construction: ");
scanf ("%d",&temp. D_cr);
} while ( (temp. D_cr<1) || (temp. D_cr> (T->tm_year+1900)));
do {
printf ("Enter new Sapacity of stadium: ");
scanf ("%d",&temp. Sapacity);
} while (temp. Sapacity<1);
do {
printf ("Enter new Amount platforms (no more 10): ");
scanf ("%d",&temp. C_pl);
} while (temp. C_pl<1||temp. C_pl>10);
for (i=0; i<temp. C_pl; i++) {
printf ("Enter new sport%d (no more 15 symbols): ", i+1);
scanf ("%s",temp. N_sp [i]);
strupr (temp. N_sp [i]);
}
printf ("Do you want change record? (Y\\N) \n");
if ( (getch () =='y') || (getch () =='Y')) {
strcpy (s [num-1]. Name,temp. Name);
s [num-1]. D_cr=temp. D_cr;
s [num-1]. Sapacity=temp. Sapacity;
s [num-1]. C_pl=temp. C_pl;
for (i=0; i<temp. C_pl; i++)
strcpy (s [num-1]. N_sp [i],temp. N_sp [i]);
alf ();
printf ("Record is changed\n"); getch ();
}
return;
}
void prin_vmes () {int i, cap;
clrscr ();
printf ("\t\t\tSEAL ON CAPACITY\n");
printf ("Choose a kind: \n");
printf ("1. =\n");
printf ("2. >\n");
printf ("3. <\n");
printf ("4. >=\n");
printf ("5. <=\n");
switch (getch ()) {
case '1': printf ("Enter capacity (=): ");
scanf ("%d",&cap);
prin_head ();
for (i=0; i<Count; i++)
if (s [i]. Sapacity==cap) prin (i);
break;
case '2': printf ("Enter capacity (>): ");
scanf ("%d",&cap);
prin_head ();
for (i=0; i<Count; i++)
if (s [i]. Sapacity>cap) prin (i);
break;
case '3': printf ("Enter capacity (<): ");
scanf ("%d",&cap);
prin_head ();
for (i=0; i<Count; i++)
if (s [i]. Sapacity<cap) prin (i);
break;
case '4': printf ("Enter capacity (>=): ");
scanf ("%d",&cap);
prin_head ();
for (i=0; i<Count; i++)
if (s [i]. Sapacity>=cap) prin (i);
break;
case '5': printf ("Enter capacity (<=): ");
scanf ("%d",&cap);
prin_head ();
for (i=0; i<Count; i++)
if (s [i]. Sapacity<=cap) prin (i);
break;
}
getch ();
return;
}
void find () { char sport [15] ; int i,j;
clrscr ();
printf ("\t\t\tSEAL KIND OF SPORT\n");
printf ("Enter sport (no more 15 symbols): ");
scanf ("%s",sport);
prin_head ();
for (i=0; i<Count; i++)
for (j=0; j<s [i]. C_pl; j++)
if (strcmp (strupr (s [i]. N_sp [j]),strupr (sport)) ==0) prin (i);
getch ();
return;
}
int main ()
{
clrscr ();
FILE* f; char c;
Count=0;
if ( (f=fopen ("C: \\Student\\05IS\\db. kp","rb")) ==NULL) {
printf ("The file does not exist\n");
fclose (f);
printf ("You want continue? (Y\\N) \n");
c=getch ();
if ( (c=='n') || (c=='N')) return 1;
}
else {
fread (&s,sizeof (s),1,f);
for (int i=0; s [i]. D_cr! =0; i++) Count=i+1;
alf ();
}
fclose (f);
while (1) {
clrscr ();
printf ("---------------------------------\n");
printf ("| Academic year project |\n");
printf ("| on Computer science |\n");
printf ("| - -----------------------------|\n");
printf ("| To create a database |\n");
printf ("| \"Stadiums of city\" |\n");
printf ("| Variant #8 |\n");
printf ("| Okunev Stanislav has executed |\n");
printf ("---------------------------------\n");
printf ("Menu: \n");
printf ("1. Add record\n");
printf ("2. Remove record\n");
printf ("3. Edit record\n");
printf ("4. Show all stadiums\n");
printf ("5. Show stadiums on capacity\n");
printf ("6. Search of stadiums by kinds of sports\n");
printf ("7. Exit\n");
printf ("Press key: ");
c=getch ();
switch (c) {
case '1': add (); break;
case '2': remov (); break;
case '3': edit (); break;
case '4': prin_all (); getch (); break;
case '5': prin_vmes (); break;
case '6': find (); break;
case '7': printf ("\nYou really want to leave? (Y\\N) \n");
c=getch ();
if ( (c=='y') || (c=='Y')) {save (); return 1; }
}
}
return 0;
}
 Комментарий модератора 
Используйте теги форматирования кода!
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
19.05.2011, 21:54
Ответы с готовыми решениями:

Найти и исправить ошибки в коде
{ссылка на сторонний ресурс удалена модератором} Кто нибудь знает где ошибка в заданиях и кодах?...

Найти и исправить ошибки в коде
Сразу прошу прощения за мат... Делаю опросник для соседа, а сам дум дум( никак не могу понять в чем...

Найти и исправить ошибки в коде
Помогите найти ошибку С #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt;

Найти факториал: исправить ошибки в коде
#include &lt;stdio.h&gt; int main() { int n; int m; n=0; m=0; scanf(&quot;%d&quot;,n); m=2; int i;

4
0 / 0 / 0
Регистрация: 15.04.2011
Сообщений: 13
20.05.2011, 13:58 2
Какие именно ошибки? логи ошибок плизз
0
0 / 0 / 0
Регистрация: 17.05.2011
Сообщений: 3
24.05.2011, 18:35  [ТС] 3
Цитата Сообщение от Dobrov Посмотреть сообщение
Какие именно ошибки? логи ошибок плизз
50: If statement missing )
60: Declaration syntax error
283: Compound statement missing }
283: `pr` is assigned a value that is never used
0
Каратель
Эксперт С++
6609 / 4028 / 401
Регистрация: 26.03.2010
Сообщений: 9,273
Записей в блоге: 1
24.05.2011, 18:39 4
ну вот и исправляйте, номера строк с ошибками есть, с английским туго? словарик вам в помощь

Добавлено через 1 минуту
Цитата Сообщение от Оля=) Посмотреть сообщение
C
1
2
3
4
5
if ( (f=fopen ("C: \\Student\\05IS\\db. kp","rb")) ==NULL) {
printf ("The file does not exist\n");
fclose (f);
printf ("You want continue? (Y\\N) \n");
c=getch ();
if скобку открыли так и закройте же ее
1
Бродяга
314 / 268 / 56
Регистрация: 27.08.2010
Сообщений: 553
24.05.2011, 18:43 5
Да не, вроде со скобками всё нормально. А вот вот операция != пишется слитно (строки 50 и 243).
1
24.05.2011, 18:43
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
24.05.2011, 18:43
Помогаю со студенческими работами здесь

Найти и исправить ошибки в приведенном коде
# include&lt;conio.h&gt; # include&lt;stdio.h&gt; # include&lt;string.h&gt; # include&lt;stdlib.h&gt; ...

Ввод/вывод структуры: найти и исправить ошибки в коде
Прога не запускатся, что-то не так с scanf. Не могу найти ошибку. #include &lt;conio.h&gt; #include...

Найти причины возникновения ошибок в коде и исправить эти ошибки
я чайник(9((((9( #include &lt;stdio.h&gt; #include &lt;math.h&gt; void main() { float x, y, z, a,...

Чтение, обработка и запись в бинарный файл. Найти и исправить ошибки в коде
Есть строка, ее надо разбить на слова с буквой d. Строку ввести с экрана, потом записать в...


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

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