Last active
February 16, 2018 14:54
-
-
Save jnovikov/5f23b24b28f803787deaa7a5372e9532 to your computer and use it in GitHub Desktop.
Struct example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
struct Student { | |
char name[100]; | |
double mark_mem; | |
double mark_cat; | |
}; | |
void print_student(Student &s) { | |
cout << "Marks of student " << s.name << " is :" << endl; | |
cout << "Catlogy: " << s.mark_cat << endl; | |
cout << "Memology: " << s.mark_mem<< endl; | |
} | |
int main() { | |
Student roma {"Roma",5.2,5.3}; //Краткая инициализация | |
Student katya {mark_cat:5, mark_mem:5.0,name:"Katya"}; | |
print_student(roma); | |
print_student(katya); | |
Student students[100]; | |
for (int i = 0 ; i < 2;i++) { | |
Student s; | |
cin >> s.name; | |
cin >> s.mark_cat; | |
cin >> s.mark_mem; | |
students[i] = s; | |
} | |
double sum = 0; | |
for (int i = 0 ; i < 2;i++) { | |
sum += students[i].mark_mem; | |
} | |
cout << sum / 2; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment