This repository was archived by the owner on Jan 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.cpp
More file actions
72 lines (63 loc) · 1.74 KB
/
program.cpp
File metadata and controls
72 lines (63 loc) · 1.74 KB
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
#include <iostream>
#include <cstring>
using namespace std;
const int SLEN = 30;
struct student{
char fullname[SLEN];
char hobby[SLEN];
int ooplevel;
};
int getinfo(student pa[],int n);
void display1(student st);
void display2(const student * ps);
void display3(const student pa[],int n);
int main(){
cout << "Podaj wielkość grupy: "; int class_size; cin >> class_size;
while(cin.get()!='\n')
continue;
student * ptr_stu = new student[class_size];
int entered = getinfo(ptr_stu,class_size);
cout << "--------------------------------\n";
cout << "***WPROWADZONE DANE***\n";
for(int i=0;i<entered;i++){
display1(ptr_stu[i]);
display2(&ptr_stu[i]);
}
cout << "--------------------------------\n";
display3(ptr_stu,entered);
delete [] ptr_stu;
cout << "Gotowe\n";
}
int getinfo(student pa[],int n){
cout << "Wprowadź dane o studentach.\n";
int index = 0; char temp[SLEN];
cout << "Student 1\nImię: "; cin.getline(temp,SLEN);
while(index<n && temp[0]!='\0'){
strcpy(pa[index].fullname,temp);
cout << "Hobby: "; cin.getline(pa[index].hobby,SLEN);
cout << "OOP Level: "; cin >> pa[index].ooplevel; cin.get();
if(++index<n){
cout << "Student " << index+1 << endl;
cout << "Imię: ";
cin.getline(temp,SLEN);
}
}
return index;
}
void display1(student st){
cout << "Imię: " << st.fullname << endl;
cout << "Hobby: " << st.hobby << endl;
cout << "OOP Level: " << st.ooplevel << endl;
cout << endl;
}
void display2(const student * ps){
cout << "Imię: " << ps->fullname << endl;
cout << "Hobby: " << ps->hobby << endl;
cout << "OOP Level: " << ps->ooplevel << endl;
cout << endl;
}
void display3(const student pa[],int n){
for(int i=0;i<n;i++){
display2(&pa[i]);
}
}