// delete.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#define m 5
#define n 2
using namespace std;
struct Fio
{
char fam[100];
char name[100];
char otchestvo[100];
};
struct Birthday
{
int day;
int mounth;
int year;
};
struct Address
{
char street[100];
char house[100];
int apart;
};
struct Mark
{
char object[100];
int grade;
};
struct STUDENT
{
Fio f;
Birthday b;
Address a;
char number[10];
char facul[100];
char group[100];
int course;
Mark M[5];
};
int main(void)
{
setlocale(LC_ALL, "rus");
/*№1*/
cout << " ---Задание №1---" << endl << " [Ввод с клавиатуры данных в массив, состоящий из 10 структур типа STUDENT]" << endl;
STUDENT s[2];
for (int i = 0; i < n; i++)
{
cout << "Familiya: "; cin >> s[i].f.fam;
cout << "Name: "; cin >> s[i].f.name;
cout << "Otchestvo: "; cin >> s[i].f.otchestvo;
cout << "Day: "; cin >> s[i].b.day;
cout << "Mounth: "; cin >> s[i].b.mounth;
cout << "Year: "; cin >> s[i].b.year;
cout << "Street: "; cin >> s[i].a.street;
cout << "House: "; cin >> s[i].a.house;
cout << "Apartment: "; cin >> s[i].a.apart;
cout << "Phone Number: "; cin >> s[i].number;
cout << "Faculty: "; cin >> s[i].facul;
cout << "Group: "; cin >> s[i].group;
cout << "Course: "; cin >> s[i].course;
cout << endl;
cout << "Mark:" << endl;
for (int j = 0; j < m; j++)
{
cout << "Object: "; cin >> s[i].M[j].object;
cout << "Grade: "; cin >> s[i].M[j].grade;
}
cout << endl;
}
cout << endl;
/*№2*/
cout << " ---Задание №2---" << endl << " [Вывод на экран данных из массива типа STUDENT]" << endl;
for (int i = 0; i < n; i++)
{
cout << "1) FIO:";
cout << s[i].f.fam << " " << s[i].f.name << " " << s[i].f.otchestvo << endl;
cout << "2) Birthday:";
cout << s[i].b.day << "." << s[i].b.mounth << "." << s[i].b.year << endl;
cout << "3) Adress";
cout << s[i].a.street << "," << s[i].a.house << "," << s[i].a.apart << endl;
cout << "4) Telephone Number:";
cout << s[i].number << endl;
cout << "5) Faculty" << " ";
cout << s[i].facul << "," << s[i].course << "," << s[i].group << endl;
cout << "6) Mark:" << endl;
for (int j = 0; j < m; j++)
{
cout << s[i].M[j].object << " : ";
cout << s[i].M[j].grade << endl;
}
}
_getch();
}
Объяснение:
cout << "Familiya: "; cin >> s[i].f.name;
cout << "Name: "; cin >> s[i].f.name;
s[i].f.fam выводило мусор, т.к. ты ничего не записал
Пример вывода в приложенном файле
5591(20), 5623(16), 5639(23), 5641(16), 5647(22), - 4
5651(17), 5653(19), 5657(23), 5659(25), 5669(26), - 1
5683(22), 5689(28), 5693(23), 5701(13), 5711(14), - 3
5717(20), 5737(22), 5741(17), 5743(19), 5749(25), - 2
5779(28), 5783(23), 5791(22), 5801(14), 5807(20), - 4
5813(17), 5821(16), 5827(22), 5839(25), 5843(20), - 3
5849(26), 5851(19), 5857(25), 5861(20), 5867(26), - 3
5869(28), 5879(29), 5881(22), 5897(29), 5903(17), - 2
5923(19), 5927(23), 5939(26), 5953(22), 5981(23), - 2
5987(29), 6007(13), 6011(09), 6029(17), 6037(16), - 1
6043(13), 6047(17), 6053(14), 6067(19), 6073(16), - 2
6079(22), 6089(23), 6091(16), 6101(08), 6113(11), - 3
6121(10), 6131(11), 6133(13), 6143(14), 6151(13), - 2
6163(17), 6173(17), 6197(23), 6199(25), 6203(11), - 0
6211(10), 6217(16), 6221(11), 6229(19), 6247(19), - 2
6257(20), 6263(17), 6269(23), 6271(16), 6277(22), - 3
6287(23), 6299(26), 6301(10), 6311(11), 6317(17), - 2
6323(14), 6329(20), 6337(19), 6343(16), 6353(17), - 3
6359(23), 6361(16), 6367(22), 6373(19), 6379(25), - 2
6389(26), 6397(25), 6421(13), 6427(19), 6449(23), - 1
6451(16), 6469(25), 6473(20), 6481(19), 6491(20), - 3
6521(14), 6529(22), 6547(22), 6551(17), 6553(19), - 3
6563(20), 6569(26), 6571(19), 6577(25), 6581(20), - 3
6599(29), 6607(19), 6619(22), 6637(22), 6653(20). - 3
Всего 120 простых чисел, из них 57 имеют четную сумму цифр.