Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- #define N 3
- struct lokator
- {
- string imie;
- string nazwisko;
- string ulica;
- string nrbloku;
- string nrmieszkania;
- };
- static void szukaj(lokator tabela[]) {
- string givenData, all;
- cout << "Podaj imie lub numer mieszkania: ";
- cin >> givenData;
- for (int i = 0; i < N; i++)
- {
- if (tabela[i].imie == givenData || tabela[i].nazwisko == givenData || tabela[i].nrbloku == givenData)
- {
- cout << endl << "Z podanych danych: " << givenData << " zostal odnaleziony mieszkaniec: " << endl;
- cout << tabela[i].imie << " " << tabela[i].nazwisko << " " << tabela[i].ulica << " " << tabela[i].nrbloku << " " << tabela[i].nrmieszkania << endl;
- }
- }
- }
- };
- int main()
- {
- string InputFile, DaneWejsciowe;
- ifstream IN;
- ofstream OUT;
- cout << "Wprowadz nazwe pliku wejsciowego: "; cin >> InputFile;
- IN.open(InputFile);
- if (!IN.is_open())
- {
- cout << ("Odczytanie pliku nie powiodlo sie!");
- return 0;
- }
- lokator lokatorzy[N];
- for (int j = 0; j<2;j++)
- {
- IN >> DaneWejsciowe;
- }
- for (int i = 0; i < N; i++)
- {
- IN >> DaneWejsciowe;
- lokatorzy[i].imie = DaneWejsciowe;
- IN >> DaneWejsciowe;
- lokatorzy[i].nazwisko = DaneWejsciowe;
- IN >> DaneWejsciowe;
- lokatorzy[i].ulica = DaneWejsciowe;
- IN >> DaneWejsciowe;
- lokatorzy[i].nrbloku = DaneWejsciowe;
- IN >> DaneWejsciowe;
- lokatorzy[i].nrmieszkania = DaneWejsciowe;
- }
- lokator::szukaj(lokatorzy);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement