Advertisement
A1exyndr

Untitled

May 26th, 2022
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <fstream>
  4. #include <iomanip>
  5. #include <stdlib.h>
  6. #include <string>
  7. #include <cctype>
  8.  
  9. using namespace std;
  10. typedef struct autoo
  11. {
  12.     char number;
  13.     char mark[25];
  14.     char color[25];
  15. }rab;
  16.  
  17. int main()
  18. {
  19.     setlocale(LC_ALL, "RUS");
  20.     int i = 0, j = 0, n = 10, k = 0; char c; char a[25];
  21.     string s;
  22.     fstream f;
  23.     rab x[10] = { {1, "BMW", "Белый"},
  24.                   {2, "BMW", "Белый"},
  25.                   {3, "Mercedes", "Черный"},
  26.                   {4, "Toyota", "Зеленый"},
  27.                   {5, "Nissan", "Красный"},
  28.                   {6, "Mercedes", "Белый"},
  29.                   {7, "BMW", "Черный"},
  30.                   {8, "Toyota", "Красный"},
  31.                   {9, "Lada", "Синий"},
  32.                   {10,"Lada", "Оранжевый"} };
  33.     rab y, g[10];
  34.     f.open("text.dat", ios::in);
  35.     cout << endl;
  36.     if (f) {
  37.  
  38.         for (i = 0; i < 10; i++) {
  39.             f.read((char*)&y, sizeof(y));
  40.             if (y.mark == "BMW" && y.color == "Белый") {
  41.                 g[k] = y;
  42.                 k++;
  43.             }
  44.         }
  45.     }
  46.     else cout << "error";
  47.     cout << "Белые BMW: \n";
  48.     for (int i = 0; i < 10; i++) {
  49.         if (y.mark == "BMW" && y.color == "Белый") {
  50.             cout << y.number << "\t" << y.mark << "\t" << y.color << "\n";
  51.         }
  52.     }
  53.         f.close();
  54.         if (k == 0) {
  55.             cout << "Таких машин нет!";
  56.         }
  57.         return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement