Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. #define N 3
  8.  
  9. struct lokator
  10. {
  11.     string imie;
  12.     string nazwisko;
  13.     string ulica;
  14.     string nrbloku;
  15.     string nrmieszkania;
  16. };
  17.  
  18.     static void szukaj(lokator tabela[]) {
  19.         string givenData, all;
  20.         cout << "Podaj imie lub numer mieszkania: ";
  21.         cin >> givenData;
  22.         for (int i = 0; i < N; i++)
  23.         {
  24.             if (tabela[i].imie == givenData || tabela[i].nazwisko == givenData || tabela[i].nrbloku == givenData)
  25.             {
  26.                 cout << endl << "Z podanych danych: " << givenData << " zostal odnaleziony mieszkaniec: " << endl;
  27.                 cout << tabela[i].imie << " " << tabela[i].nazwisko << " " << tabela[i].ulica << " " << tabela[i].nrbloku << " " << tabela[i].nrmieszkania << endl;
  28.             }
  29.         }
  30.  
  31.     }
  32. };
  33.  
  34.  
  35. int main()
  36. {
  37.     string InputFile, DaneWejsciowe;
  38.  
  39.     ifstream IN;
  40.     ofstream OUT;
  41.  
  42.     cout << "Wprowadz nazwe pliku wejsciowego: "; cin >> InputFile;
  43.  
  44.     IN.open(InputFile);
  45.     if (!IN.is_open())
  46.     {
  47.         cout << ("Odczytanie pliku nie powiodlo sie!");
  48.         return 0;
  49.     }
  50.  
  51.     lokator lokatorzy[N];
  52.     for (int j = 0; j<2;j++)
  53.     {
  54.         IN >> DaneWejsciowe;
  55.     }
  56.     for (int i = 0; i < N; i++)
  57.     {
  58.         IN >> DaneWejsciowe;
  59.         lokatorzy[i].imie = DaneWejsciowe;
  60.  
  61.         IN >> DaneWejsciowe;
  62.         lokatorzy[i].nazwisko = DaneWejsciowe;
  63.  
  64.         IN >> DaneWejsciowe;
  65.         lokatorzy[i].ulica = DaneWejsciowe;
  66.  
  67.         IN >> DaneWejsciowe;
  68.         lokatorzy[i].nrbloku = DaneWejsciowe;
  69.  
  70.         IN >> DaneWejsciowe;
  71.         lokatorzy[i].nrmieszkania = DaneWejsciowe;
  72.     }
  73.  
  74.     lokator::szukaj(lokatorzy);
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement