Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.4 kB
2
Indexable
Never
#include <iostream>
#include <vector>
#include <Windows.h>
using namespace std;

struct stud
{
	string name;
	string birth;
	vector <float> marks;
};

void GetData(stud* list, int n)
{
	for (int i = 0; i < n; i++)
	{
		string name1, name2, name3;
		string name;
		float mark;

		cout << "ФИО - ";
		cin >> name1 >> name2 >> name3;
		list[i].name = name1 + " " + name2 + " " + name3;
		cout << "Год рождения - ";
		cin >> list[i].birth;

		for (int j = 0; j < 4; j++)
		{
			cout << "оценка " << j + 1 << endl;
			cin >> mark;
			list[i].marks.push_back(mark);
		}

	}

}

void ShowData(stud* list, int n)
{
	cout << "ФИО - Год рождения - Средний балл" << endl;

	for (int i = 0; i < n; i++)
	{
		float sum_mark = 0;

		for (int j = 0; j < 4; j++)
		{
			sum_mark += list[i].marks[j];
		}

		if (sum_mark == 20)
			cout << list[i].name << " - " << list[i].birth 
			<< " - " << sum_mark / 4 << " - отличник" << endl;
		else
			cout << list[i].name << " - " << list[i].birth 
			<< " - " << sum_mark / 4 << endl;
	}

}

void main()
{
	SetConsoleCP(1251);
	setlocale(LC_ALL, "Russian");

	int n;
	cout << "Количество студентов - ";
	cin >> n;
	
	stud* list = new stud[n];
	GetData(list, n);
	ShowData(list, n);
	delete[]list;
}