
Сообщение от
Alex566
Строки в структуре динамические по этому ошибку выдавало.
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
| #include <iostream>
#include <string.h>
using namespace std;
const int n=3;
struct student
{
char FIO[256];
char nomer_gruppy[50];
struct uspevaemost
{
char predmet[100];
int ocenka;} usp[4];
};
void main()
{
student a[n];
int best_ocenka;
for (int i = 0; i < n; i++)
{
cout<<"Vvedite dannye o "<<i+1<<"-m studente:\n";
cout<<"VVedite Familiyu i inicialy:\n"; cin.ignore(1,'\n'); gets(a[i].FIO);
cout<<"Vvedite nomer gruppy:\n"; gets(a[i].nomer_gruppy);
for(int j=0; j<4; j++)
{
cout<<"Vvedite "<<j+1<<" predmet:\n"; cin.ignore(1,'\n'); gets(a[i].usp[j].predmet);
cout<<"Vvedite ocenku po nemu:\n"; cin>>a[i].usp[j].ocenka;
}
}
for (int i = 0; i < n; i++)
{
best_ocenka = a[i].usp[0].ocenka;
for(int j=1; j<4; j++)
if (a[i].usp[j].ocenka > best_ocenka)
best_ocenka = a[i].usp[j].ocenka;
cout<<a[i].FIO<<" iz "<<a[i].nomer_gruppy<<" gruppy. Luchschaya ocenka: "<<best_ocenka<<endl;
}
system("pause");
} |
|
От части это помогло, спасибо ))) но теперь программа некорректно считывает данные, проскакивая некоторые поля((
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
| #include <iostream.h>
#include <stdio.h>
#include <string.h>
using namespace std;
struct student
{
char FIO[25];
char nomer_gruppy[6];
struct uspevaemost
{
char predmet[30];
int ocenka;} usp[4];
};
void main()
{
const int n=3;
student a[n];
int best_ocenka;
for (int i = 0; i < n; i++)
{
cout<<"Vvedite dannye o "<<i+1<<"-m studente:\n";
cout<<"VVedite Familiyu i inicialy:\n"; gets(a[i].FIO);
cout<<"Vvedite nomer gruppy:\n"; gets(a[i].nomer_gruppy);
for(int j=0; j<4; j++)
{
cout<<"Vvedite "<<j+1<<" predmet:\n"; gets(a[i].usp[j].predmet);
cout<<"Vvedite ocenku po nemu:\n"; cin>>a[i].usp[j].ocenka;
}
}
for (int i = 0; i < n; i++)
{
best_ocenka = (int)(a[i].usp[0].ocenka);
for(int j=1; j<4; j++)
if ((int)(a[i].usp[j].ocenka) > best_ocenka)
best_ocenka = (int)(a[i].usp[j].ocenka);
cout<<a[i].FIO<<" iz "<<a[i].nomer_gruppy<<" gruppy. Luchschaya ocenka: "<<best_ocenka<<endl;
}
system("pause");
} |
|
И скрин ввода во вложении