SHARE
TWEET

Untitled

a guest Apr 19th, 2019 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. #define STUDENT_COUNT 5
  5.  
  6. using namespace std;
  7.  
  8. struct Student
  9. {
  10.     string name = "Ivan";
  11.     int age = 19;
  12.     string group = "IKBO-45-98";
  13. };
  14.  
  15. int main() {
  16.  
  17.     vector<Student> students(STUDENT_COUNT);
  18.     while (true)
  19.     {
  20.         cout << "Do you want to change any student? (y/n)\n";
  21.         char answer;
  22.         cin >> answer;
  23.         if (answer != 'y' && answer != 'n')
  24.             continue;
  25.         else
  26.         {
  27.             if (answer == 'n') break;
  28.             else
  29.             {
  30.                 int index;
  31.                 while (true)
  32.                 {
  33.                     cout << "Enter index of student:\n";
  34.                     cin >> index;
  35.                     if (index >= STUDENT_COUNT) continue;
  36.                     break;
  37.                 }
  38.                 cout << "Enter name, age, group of " << index << " student:\n";
  39.                 cin >> students[index].name >> students[index].age >> students[index].group;
  40.             }
  41.         }
  42.     }
  43.  
  44.     cout << "list of students:\n";
  45.     int i = 0;
  46.     for (auto &student : students)
  47.         cout << i++ << ") "
  48.              << student.name
  49.              << " of age "
  50.              << student.age
  51.              << " in group "
  52.              << student.group << ".\n";
  53.  
  54.     return 0;
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top