Advertisement
Guest User

ебал двачь(сорри)

a guest
Apr 13th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.48 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include <string>
  4.  
  5. #include <locale.h>
  6.  
  7. #include <windows.h>
  8.  
  9. #include <stdlib.h>
  10.  
  11. #include <fstream>
  12.  
  13. #include <vector>
  14. using namespace std;
  15.  
  16. struct Kniga
  17. {
  18.     char name[25];
  19.     char author[25];
  20.     long year;
  21. };
  22.  
  23. void Viborka(Kniga* a, int n)
  24. {
  25.     Kniga* poisk = new Kniga[n];
  26.     cout << endl << "Введите параметры книги которую вы хотите найти: ";
  27.     for (int i = 0; i < 1; i++)
  28.     {
  29.  
  30.         cout << endl << "Автор книги: ";
  31.  
  32.         cin >> poisk[i].author;
  33.  
  34.         cout << "Год, до которого книга выпущена: ";
  35.  
  36.         cin >> poisk[i].year;
  37.     }
  38.     for (int i = 0; i < n; i++)
  39.     {
  40.         if (poisk[i].author == a[i].author && a[i].year <= poisk[i].year)
  41.         {
  42.             cout << "Найдена подходящая вам книга:" << "\n";
  43.  
  44.             cout << "Название: " << a[i].name;
  45.  
  46.             cout << "\n";
  47.  
  48.             cout << "Автор: " << a[i].author;
  49.  
  50.             cout << "\n";
  51.  
  52.             cout << "Год: " << a[i].year;
  53.  
  54.             cout << "\n";
  55.  
  56.         }
  57.         else cout << endl << "Подходящая вам книга не найдена." << "\n";
  58.     }
  59.  
  60. }
  61.  
  62. int main()
  63. {
  64.     setlocale(LC_ALL, "Russian");
  65.     SetConsoleCP(1251);
  66.     SetConsoleOutputCP(1251);
  67.     int n;
  68.     cout << "Введите количество книг \n";
  69.     cin >> n;
  70.     Kniga* a = new Kniga[n];
  71.     int  i;
  72.     for (i = 0; i < n; i++)
  73.  
  74.     {
  75.  
  76.         cout << "Введите название книги\n";
  77.  
  78.         cin >> a[i].name;
  79.  
  80.         cout << "Введите имя автора\n";
  81.  
  82.         cin >> a[i].author;
  83.  
  84.         cout << "Введите год издания\n";
  85.  
  86.         cin >> a[i].year;
  87.  
  88.     }
  89.     for (i = 0; i < n; i++)
  90.  
  91.     {
  92.  
  93.         cout << "\nНазвание книги:" << a[i].name << endl;
  94.        
  95.         cout << "Автор книги:" << a[i].author << endl;
  96.        
  97.         cout << "Год издания:" << a[i].year << endl;
  98.  
  99.  
  100.     }
  101.  
  102.  
  103.     int input;
  104.  
  105. menu:
  106.  
  107.     cout << endl << "1. Произвести выборку книг" << endl;
  108.    
  109.     cout << endl << "2. Выйти" << endl;
  110.    
  111.     cout << endl << "Введите цифру: ";
  112.  
  113.     cin >> input;
  114.  
  115.     cout << endl << "\n";
  116.  
  117.     switch (input)
  118.     {
  119.  
  120.         case 1:
  121.             Viborka(a, n);
  122.             goto menu;
  123.         case 2:
  124.             exit;
  125.     }
  126.  
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement