Advertisement
ULK

СТРУКТУРЫ

ULK
May 2nd, 2023
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.07 KB | None | 0 0
  1. #include <iostream>
  2. #pragma warning(disable : 4996)
  3. using namespace std;
  4.  
  5. struct series
  6. {
  7.     char name[100];
  8.     int age;
  9.     int year;
  10.     double rating;
  11.     double veiws;
  12.     bool ongoing;
  13.     bool original;
  14.     int season;
  15.     int episodes;
  16.     double minutes;
  17.     int best_episodes[15];
  18. };
  19. int main() {
  20.     typedef struct series s;
  21.     const int n = 5;
  22.     s st[n]{};
  23.     strcpy(st[0].name, "game of thrones");              //кстати не важно какое имя введешь, всё равно генерирует по структуре
  24.     strcpy(st[1].name, "doctor who");
  25.     strcpy(st[2].name, "house of the dragon");
  26.     strcpy(st[3].name, "elementary");
  27.     strcpy(st[4].name, "misfits");
  28.  
  29.     for (int i = 0; i < n; i++)
  30.     {
  31.         cout << "\n" << "enter the name of series: ";
  32.         cin >> st[i].name;
  33.         st[i].age = rand() % 3 + 16;                    //возрастное ограничение - примерно работает
  34.         cout << "\n" << "age " << st[i].age;
  35.         st[i].year = rand() % 10 + 2000;
  36.         cout << "\n" << "year " << st[i].year;
  37.         st[i].rating = rand() % 10;
  38.         cout << "\n" << "rating " << st[i].rating;
  39.         st[i].veiws = rand();
  40.         cout << "\n" << "veiws " << st[i].veiws;
  41.         st[i].ongoing = rand() % 2;
  42.         cout << "\n" << "ongoing " << st[i].ongoing;
  43.         st[i].original = rand() % 2;
  44.         cout << "\n" << "original " << st[i].original;
  45.         st[i].season = rand() % 10;
  46.         cout << "\n" << "season " << st[i].season;
  47.         st[i].episodes = rand() % 10 + 10;
  48.         cout << "\n" << "episodes " << st[i].episodes;
  49.         st[i].minutes = rand() % 40 + 10;
  50.         cout << "\n" << "minutes " << st[i].minutes;
  51.  
  52.         cout << "\n" << "best_episodes ";
  53.         for (int k = 0; k < 15; k++)                    //сделать так, чтобы числа не повторялись!!!
  54.         {
  55.             st[i].best_episodes[k] = rand() % 10 + 5;
  56.             cout << " " << st[i].best_episodes[k];
  57.         }
  58.  
  59.         cout << "\n";
  60.     }
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement