Skip to content

Instantly share code, notes, and snippets.

@jnovikov
Last active February 16, 2018 14:54
Show Gist options
  • Save jnovikov/5f23b24b28f803787deaa7a5372e9532 to your computer and use it in GitHub Desktop.
Save jnovikov/5f23b24b28f803787deaa7a5372e9532 to your computer and use it in GitHub Desktop.
Struct example
#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