SysOp
42 / 41 / 5
Регистрация: 13.04.2009
Сообщений: 274
|
|
1
|
Вектор и итераторы
19.01.2010, 14:31. Показов 723. Ответов 1
Всем привет. Помогите дописать курсовую. Нодо сделать вывод студентов с вектора + сортировку объектов в векторе по любому значению. Вот что у меня получилось:
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
| ///////////////////////////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <conio.h>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <locale.h>
///////////////////////////////////////////////////////////////////////////////////////////////////////
COORD cd;
HANDLE hd = GetStdHandle(STD_OUTPUT_HANDLE);
///////////////////////////////////////////////////////////////////////////////////////////////////////
class Group
{
protected:
char groupName[10];
};
class Discipline
{
protected:
int markMath;
int markOOP;
int markPhys;
int markEcon;
int markEngl;
int markOC;
int markFilo;
char professorFirstName[20];
char professorSecondName[20];
};
class Internships
{
protected:
char program[15];
char place[15];
char dateAndTime[15];
};
class Student: protected Discipline, protected Group, protected Internships
{
protected:
char secondName[20];
char firstName[20];
int dDay;
int dMounth;
int dYear;
char street[20];
int buldNumber;
int homeNumber;
char phoneNumber[20];
public:
int showStudents()
{
int rating = markMath + markOOP + markPhys + markEcon + markEngl + markOC + markFilo;
return firstName,secondName,groupName,rating;
}
};
///////////////////////////////////////////////////////////////////////////////////////////////////////
void _tmain(int argc, _TCHAR* argv[])
{
setlocale(0,"russian");
ifstream inStud;
inStud.open("Files/Students.txt", ios::app | ios::out | ios::in | ios::binary );
vector<Student> STUD;
vector<Student>::iterator STUDiter;
do
{
Student S;
inStud.read(reinterpret_cast<char*>(&S),sizeof(S));
if(inStud.eof()){break;}
S.showStudents();
STUD.push_back(S);
}
while(1);
inStud.close();
cout<<"--------------------------------------------------------------------------------"<<endl;
cd.X=4;cd.Y=2;SetConsoleCursorPosition(hd,cd);
cout<<"ID"<<endl;
cd.X=15;cd.Y=2;SetConsoleCursorPosition(hd,cd);
cout<<"Прiзвище та iмя"<<endl;
cd.X=45;cd.Y=2;SetConsoleCursorPosition(hd,cd);
cout<<"Група"<<endl;
cd.X=62;cd.Y=2;SetConsoleCursorPosition(hd,cd);
cout<<"Рейтинг"<<endl;
//===========================//
// Вивід студентів з вектора //
/*while (STUDiter!= STUD.end ())
{
cout<<(*STUDiter);
STUDiter++;
}*/
//===========================//
cout<<endl<<"--------------------------------------------------------------------------------"<<endl;
cout<<" Натиснiть будь-яку клавiшу щоб вийти з програми..."<<endl;
getch();
system("cls");
return;
} |
|
0
|