Nelogeek

Untitled

Oct 24th, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. struct ZNAK
  7. {
  8.     string NAME[2];// фамилия имя
  9.     string ZODIAK;
  10.     int BDAY[3];//dd mm yyyy
  11.     double AV_SCORE;//средний балл
  12. };
  13.  
  14. double average_score(double* arr, int size) //функция нахождения среднего арифметического
  15. {
  16.     double average;
  17.     double temp = 0;
  18.     for (int i = 0; i < size; i++)
  19.     {
  20.         temp += arr[i];
  21.     }
  22.     average = temp / size;
  23.     return average;
  24. }
  25.  
  26. void bubbleSort(ZNAK temp[], size_t size) {
  27.     long i, j;
  28.     ZNAK x;
  29.  
  30.     for (i = 0; i < size; i++) {
  31.         for (j = size - 1; j > i; j--) {
  32.             if (temp[j - 1].BDAY[0] > temp[j].BDAY[0]) {
  33.                 x = temp[j - 1]; temp[j - 1] = temp[j]; temp[j] = x;
  34.             }
  35.         }
  36.     }
  37.     for (i = 0; i < size; i++) {
  38.         for (j = size - 1; j > i; j--) {
  39.             if (temp[j - 1].BDAY[1] > temp[j].BDAY[1]) {
  40.                 x = temp[j - 1]; temp[j - 1] = temp[j]; temp[j] = x;
  41.             }
  42.         }
  43.     }
  44.     for (i = 0; i < size; i++) {          
  45.         for (j = size - 1; j > i; j--) {  
  46.             if (temp[j - 1].BDAY[2] > temp[j].BDAY[2]) {
  47.                 x = temp[j - 1]; temp[j - 1] = temp[j]; temp[j] = x;
  48.             }
  49.         }
  50.     }
  51. }
  52.  
  53. int main()
  54. {
  55.     setlocale(LC_ALL, "Russian");
  56.  
  57.     const int size = 2; // количество человек
  58.     ZNAK BOOK[size];
  59.     for (int i = 0; i < size; i++)  // ввод информации
  60.     {
  61.         cout << "Введите фамилию и имя" << endl;
  62.         for (int j = 0; j < 2; j++)
  63.             cin >> BOOK[i].NAME[j];
  64.         cout << "Введите знак зодиака" << endl;
  65.         cin >> BOOK[i].ZODIAK;
  66.         cout << "Введите ДЕНЬ рождения" << endl;
  67.         cin >> BOOK[i].BDAY[0];
  68.         cout << "Введите МЕСЯЦ рождения" << endl;
  69.         cin >> BOOK[i].BDAY[1];
  70.         cout << "Введите ГОД рождения" << endl;
  71.         cin >> BOOK[i].BDAY[2];
  72.  
  73.     }
  74.  
  75.     bubbleSort(BOOK, size);//сортировка
  76.     for (auto SOMEONE : BOOK) {
  77.         cout << SOMEONE.NAME[0] << " " << SOMEONE.NAME[1] << endl;
  78.         cout << SOMEONE.BDAY[0] << "." << SOMEONE.BDAY[1] << "." << SOMEONE.BDAY[2] <<endl;
  79.     }
  80.  
  81.     cout << "Введите знак человека, которого нужно найти" << endl;
  82.     string znak;
  83.     cin >> znak;
  84.     bool check = true;
  85.     for (auto SOMEONE : BOOK) {
  86.         if (SOMEONE.ZODIAK == znak) {
  87.             cout << "Фамилия: " << SOMEONE.NAME[0] << endl;
  88.             cout << "Имя: " << SOMEONE.NAME[1] << endl;
  89.             cout << "Знак зодиака: " << SOMEONE.ZODIAK << endl;
  90.             cout << "Дата рождения: " << SOMEONE.BDAY[0] << "." << SOMEONE.BDAY[1] << "." << SOMEONE.BDAY[2] << endl;
  91.  
  92.             check = false;
  93.         }
  94.        
  95.     }
  96.     if (check)
  97.         cout << "Такой знак не найден";
  98. }
Advertisement
Add Comment
Please, Sign In to add comment