Filage

Struct1

Mar 4th, 2024
833
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.71 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct Price {
  6.     int rubles;
  7.     int coins;
  8. };
  9.  
  10. struct Time {
  11.     int hours;
  12.     int minutes;
  13.     int seconds;
  14. };
  15.  
  16. struct Date {
  17.     int day;
  18.     int month;
  19.     int year;
  20. };
  21.  
  22. struct Address {
  23.     int index;
  24.     string town;
  25.     string street;
  26.     int house;
  27.     int apartment;
  28. };
  29.  
  30. struct Student {
  31.     string lastName;
  32.     int recordBookNumber;
  33.     int examGrade;
  34. };
  35.  
  36. struct Exam {
  37.     string subject;
  38.     int groupNumber;
  39.     Date examDate;
  40.     Student students[25];
  41. };
  42.  
  43. int main() {
  44.     setlocale(LC_ALL, "Rus");
  45.     Price itemPrice = { 52, 99 };
  46.     struct Price* price_ptr = &itemPrice;
  47.     cout << "Цена: " << price_ptr->rubles << " рублей " << itemPrice.coins << " копеек" << endl;
  48.  
  49.     Time currentTime = { 10, 30, 45 };
  50.     cout << "Текущее время: " << currentTime.hours << ":" << currentTime.minutes << ":" << currentTime.seconds << endl;
  51.  
  52.     Date currentDate = { 7, 2, 2024 };
  53.     cout << "Текущая дата: " << currentDate.day << "." << currentDate.month << "." << currentDate.year << endl;
  54.  
  55.     Address currentAddress = { 123456, "Москва", "Ленина", 10, 5 };
  56.     cout << "Адрес: " << currentAddress.index << ", " << currentAddress.town << ", " << currentAddress.street
  57.          << ", д." << currentAddress.house << ", кв." << currentAddress.apartment << endl;
  58.  
  59.     Student students[25] = { {"Петров", 1, 90}, {"Сидоров", 2, 75}, {"Соколов", 3, 99 }, {"Михайлов", 4, 98 }, {"Новиков", 5, 97 }, {"Федоров", 6, 94 }, {"Морозов", 7, 93 },
  60.                              {"Алексеев", 8, 90 }, {"Козлов", 9, 99 }, {"Степанов", 10, 88 }, {"Орлов", 11, 36 }, {"Андреев", 12, 81 }, {"Макаров", 13, 67 }, {"Никитин", 14, 22 },
  61.                              {"Захаров", 15, 94 }, {"Романов", 16, 78 }, {"Чернов", 17, 55 }, {"Григорьев", 18, 41 }, {"Поляков", 19, 63 }, {"Кудрявцев", 20, 73 }, {"Калинин", 21, 45 },
  62.                              {"Максимов", 22, 60 }, {"Лазарев", 23, 27 }, {"Ефимов", 24, 52 }, {"Беляев", 25, 1 } };
  63.     Exam exam1 = { "Математика", 1, {15, 2, 2024}};
  64.     for (int i = 0; i < 25; ++i) {
  65.         exam1.students[i] = students[i];
  66.     }
  67.     cout << "Экзамен по " << exam1.subject << " для группы " << exam1.groupNumber << " состоится "
  68.          << exam1.examDate.day << "." << exam1.examDate.month << "." << exam1.examDate.year << ". \nСписок студентов и оценок:"
  69.          << endl;
  70.     for (int i = 0; i < 25; ++i) {
  71.         cout << "Студент: " << exam1.students[i].lastName << ", номер зачетной книжки: " << exam1.students[i].recordBookNumber << ", оценка: " << exam1.students[i].examGrade << endl;
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment