Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7. fstream dzieci_plik("DZIECI.txt");
  8. fstream preferencje_plik("PREFERENCJE.txt");
  9. fstream przedszkola_plik("PRZEDSZKOLA.txt");
  10. if(dzieci_plik.good() && preferencje_plik.good() && przedszkola_plik.good()){
  11.  
  12. // prweferencje z przedszkolem o id 76
  13. int typ=0;// Pesel;Numer_preferencji;Id_przedszkola
  14. string preferencja[3];
  15. for (string pole; getline(preferencje_plik, pole, ';'); ) {
  16. preferencja[typ]=pole;
  17. if(typ==2){
  18. if(preferencja[2]=="76"){
  19. cout<<preferencja[2];
  20. }
  21. typ=0;
  22. } else{
  23. typ++;
  24. }
  25.  
  26. }
  27. return 0;
  28.  
  29. // wszystkie dziewczynki
  30. typ=0;// Pesel;Nazwisko;Imie;Plec;Wiek
  31. string dziecko[5];
  32. for (string pole; getline(dzieci_plik, pole, ';'); ) {
  33. dziecko[typ]=pole;
  34. if(typ==4){// uzyskano caly rekord
  35. if(dziecko[3]=="dziewczynka"){
  36. cout<<dziecko[2]<<' '<<dziecko[1]<<'\n';
  37. }
  38. typ=0;
  39. }
  40. typ++;
  41. }
  42.  
  43. } else {
  44. cout<<"Błąd plików";
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement