Advertisement
Shaybaaa

Untitled

Feb 18th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. //Zadania 2 i 4
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <fstream>
  5. using namespace std;
  6. int main()
  7. {
  8. fstream file;
  9. file.open("liczby.txt");
  10. int x;
  11. int min=99999999;
  12. int max=-99999999;
  13. for (int i=0; i<1000; i++)
  14. {
  15. int s=0;
  16. file>>x;
  17. cout<<x<<"-> ";
  18. for (int d=2; d<=x; d++)
  19. {
  20. while (x%d==0)
  21. {
  22. cout<<d<<", ";
  23. x=x/d;
  24. s=s+x;
  25. }
  26. }
  27. for (int z=0; z<1000; z++)
  28. {
  29. if (s>max)
  30. {
  31. max=s;
  32. }
  33. if (s<min)
  34. {
  35. min=s;
  36. }
  37. }
  38. cout<<endl;
  39. }
  40. cout<<"Min= "<<min<<endl;
  41. cout<<"Max= "<<max<<endl;
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement