Если тебе ещё надо то вот... когда то писал
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
| #include <iostream.h>
#include <string.h>
#include <conio.h>
class progress;
class student
{
friend ostream &operator<<(ostream &, const student&);
friend istream &operator>>(istream &, student &);
private:
friend class progress;
student *next;
char *name;
float mark;
public:
void Ras();
void PrintStudent() {cout<<"Student "<<name<<" have mark "<<mark<<endl;}
void ReadStudent()
{
cout<<"Enter name: ";
cin>>name;
cout<<"Enter mark: ";
cin>>mark;
}
student();
};
student::student()
{
int k=10;
name=new char[k+1];
strcpy(name,"With Out Name");
mark=0;
}
void student::Ras()
{
student *s;
float fin=0;
while(s)
{
fin+=mark;
s=s->next;
}
cout<<fin<<endl;
}
class progress
{
int count;
char Facultet[20];
student *first;
student *head;
public:
progress(char *FacultetName) //ÏðèñâîåГ*ГЁ èìåГ*ГЁ Г”Г*êóëüòåòó
{
strcpy(Facultet, FacultetName);
count=0;
first=head=NULL;
}
void AddStudent();
void PrintAll();
~progress();
};
progress::~progress()
{
if (count)
{
student *s=first;
while (s)
{
s=first->next;
delete first;
first=s;
}
}
}
void progress::AddStudent()
{
if (!count) {
first=new student;
head=first;
head->next=NULL;
head->ReadStudent();
count=1;
} else {
head->next=new student;
head=head->next;
head->ReadStudent();
head->next=NULL;
count++;
}
}
void progress::PrintAll()
{
student *s;
s=first;
while(s)
{
s->PrintStudent();
s=s->next;
}
}
istream &operator>>(istream&input, student &s)
{
input>>s.name;
return input;
}
ostream &operator<<(ostream &output, const student &s)
{
output <<s.name << s.mark<< ' ' <<endl;
return output;
}
void main()
{
progress P("PS");
student S;
char s=0;
while(s!=27)
{
P.AddStudent();
s=getch();
}
P.PrintAll();
S.Ras();
} |
|
Добавлено через 42 секунды
Это не совсем то но может тебе что-то пригодиться от сюда