Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. // Napisz fragment programu ktory z pliku "dane.txt" wczytuje dane do tablicy A[n] (n - stala)
  5. // i drukuje sume elementow wiekszych od stalej H.
  6. // Nalezy zdefiniowac potrzebne stale i zmienne
  7.  
  8. using namespace std;
  9. int main()
  10. {
  11. const int rozmiar_tablicy = 5;
  12. int tablica[rozmiar_tablicy];
  13. int tmp = 0;
  14. const int H = 5;
  15. int temp2 = 0;
  16.  
  17. ifstream liczby("dane.txt");
  18.  
  19. while (!liczby.eof())
  20. liczby >> tablica[tmp++];
  21.  
  22. liczby.close();
  23.  
  24. cout << "Wyswietlenie danych z pliku" << endl;
  25. for (int i=0; i<tmp; i++) {
  26. cout << tablica[i] << endl;
  27. }
  28.  
  29. cout << "Liczby wieksze od zmiennej H (" << H << ")" << endl;
  30.  
  31. for (int i=0; i<tmp; i++) {
  32. temp2 = tablica[i];
  33. cout << "Sprawdzanie liczby " << temp2 << endl;
  34. if(temp2 > 5){
  35. cout << temp2 << endl;
  36. }
  37. }
  38.  
  39.  
  40. getchar();
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement