SHARE
TWEET

Parasha kakayato

daniil_mironoff Mar 26th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int const num = 8;
  7.  
  8. struct NOTE {
  9.     string NAME;
  10.     string TELE;
  11.     int BDAY[3];
  12.  
  13. };
  14.  
  15. void input_num_show_info(NOTE info[]) {
  16.     string tel;
  17.     cout << "Введите TELE: ";
  18.     cin >> tel;
  19.    
  20.     for (int i = 0; i < num; i++) {
  21.         if (info[i].TELE == tel) {
  22.             cout << "Найден: " << info[i].NAME;
  23.            
  24.             for (int j = 0; j < 3; j++) {
  25.                 cout << " " << info[i].BDAY[j];
  26.             }
  27.            
  28.             cout << endl;
  29.         }
  30.     }
  31. }
  32.  
  33. int main() {
  34.     NOTE BLOCKNOTE[num];
  35.     for (int i = 0; i < num; i++) {
  36.         cout << "BLOCKNOTE[" << i << "]" << endl;
  37.         cout << "Введите NAME: ";
  38.         cin >> BLOCKNOTE[i].NAME;
  39.         cout << "Введите TELE: ";
  40.         cin >> BLOCKNOTE[i].TELE;
  41.        
  42.         for (int j = 0; j < 3; j++) {
  43.             cout << "Введите BDAY[" << j << "]: ";
  44.             cin >> BLOCKNOTE[i].BDAY[j];
  45.         }
  46.        
  47.         cout << endl;
  48.     }
  49.    
  50.     for (int i = 0; i < num; i++) {
  51.         for (int j = 0; j < num - i - 1; j++) {
  52.             int sum_left = BLOCKNOTE[j].BDAY[0] + BLOCKNOTE[j].BDAY[1] * 30 + BLOCKNOTE[j].BDAY[2] * 365;
  53.             int sum_right = BLOCKNOTE[j + 1].BDAY[0] + BLOCKNOTE[j + 1].BDAY[1] * 30 + BLOCKNOTE[j + 1].BDAY[2] * 365;
  54.            
  55.             if (sum_left > sum_right) {
  56.                 string str_buffer;
  57.                 int int_buffer;
  58.                
  59.                 str_buffer = BLOCKNOTE[j].NAME;
  60.                 BLOCKNOTE[j].NAME = BLOCKNOTE[j + 1].NAME;
  61.                 BLOCKNOTE[j + 1].NAME = str_buffer;
  62.                
  63.                 str_buffer = BLOCKNOTE[j].TELE;
  64.                 BLOCKNOTE[j].TELE = BLOCKNOTE[j + 1].TELE;
  65.                 BLOCKNOTE[j + 1].TELE = str_buffer;
  66.    
  67.                 for (int k = 0; k < 3; k++) {
  68.                     int_buffer = BLOCKNOTE[j].BDAY[k];
  69.                     BLOCKNOTE[j].BDAY[k] = BLOCKNOTE[j + 1].BDAY[k];
  70.                     BLOCKNOTE[j + 1].BDAY[k] = int_buffer;
  71.                 }
  72.             }
  73.         }
  74.     }
  75.    
  76.     input_num_show_info(BLOCKNOTE);
  77.    
  78.     return 0;
  79. }
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