fork download
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main () {
  6.  
  7. int x, y, ile_wiel = 0, nwd = 0;
  8.  
  9. ifstream odczyt("PARY_LICZB.TXT");
  10. if(!odczyt) {
  11. cout << "Blad odczytu!";
  12. return 0;
  13. }
  14.  
  15. ofstream zapis("ZADANIE5.TXT");
  16. if(!zapis) {
  17. cout << "Blad zapisu!";
  18. return 0;
  19. }
  20.  
  21. for(int i=0;i<1000;i++) {
  22. odczyt >> x >> y;
  23. cout << x << " " << y << endl;
  24. zapis << x << " " << y << endl;
  25. if(x%y==0 || y%x==0) ile_wiel++;
  26. while(x!=y) {
  27. if(x>y)
  28. x-=y; //lub a = a - b;
  29. else
  30. y-=x; //lub b = b-a
  31. }
  32. if(x==1 || y==1) nwd++;
  33.  
  34. }
  35.  
  36. zapis << "Wielokrotnosci: " << ile_wiel << endl;
  37. zapis << "NWD: " << nwd << endl;
  38.  
  39. odczyt.close();
  40. zapis.close();
  41. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Blad odczytu!