alsav22
5434 / 4829 / 442
Регистрация: 04.06.2011
Сообщений: 13,587
|
08.04.2013, 07:24
|
|
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
| #include <fstream>
#include <iostream>
using namespace std;
const int N = 20;
const int S = 5;
const int L = 800;
struct student
{
char name[N];
int group;
int course;
int sesia[S];
};
int main()
{
setlocale(0, "");
ifstream fin;
fin.open("student.txt", ios::in);
if (!fin.is_open())
{
cerr << "Error!" << endl;
system("pause");
return 1;
}
char s[L];
size_t counter;
for (counter = 0; !fin.eof(); counter++)
fin.getline(s, L);
student *study = new student[counter];
fin.clear();
fin.seekg(0);
for (int i = 0; i < counter; i++)
{
fin.getline(study[i].name, N, ':');
study[i].group = (fin.get() - 48);
fin.seekg(1, ios::cur);
study[i].course = (fin.get() - 48);
for(int j = 0; j < S; j++)
{
fin.seekg(1, ios::cur);
study[i].sesia[j] = (fin.get() - 48);
}
fin.seekg(3, ios::cur);
}
for (int i = 0; i < counter; ++i)
{
cout << study[i].name << ':';
cout << study[i].group << ':';
cout << study[i].course << ':';
for(int j = 0; j < S; j++)
cout << study[i].sesia[j] << ':';
cout << endl;
}
cout << endl;
system("pause");
return 0;
}} |
|
0
|