Advertisement
Shaybaaa

zadanie1i3

Feb 18th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. //Zadania 1 i 3
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <fstream>
  5. using namespace std;
  6. int main(int argc, char** argv)
  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=1; d<x; d++)
  19.         {
  20.             if (x%d==0)
  21.             {
  22.                 cout<<d<<", ";
  23.                 s=s+d;
  24.             }
  25.         }
  26.         cout<<endl;
  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.     }
  39.     cout<<"Min= "<<min<<endl;
  40.     cout<<"Max= "<<max<<endl;
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement