Advertisement
zerokarahajimerumaho

cpp3

Dec 11th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. /*
  2. https://cke.gov.pl/images/_EGZAMIN_MATURALNY_OD_2015/Arkusze_egzaminacyjne/2016/formula_od_2015/MIN-R1_1P-162.pdf
  3. Liczby skojarzone
  4. */
  5.  
  6. #include <iostream>
  7. using namespace std;
  8. int main()
  9. {
  10.     int t,r,k,j,p=0;
  11.     cin>>k,r;
  12.     for(int a=0;a<2;a++)
  13.     {
  14.         int *l, *w;
  15.         if(a==0) {l=&k; w=&r;}
  16.         if(a==1) {l=&r; w=&k;}
  17.         cout<<"Dzielniki: ";
  18.         t=0;
  19.     for(int i=1;i<(*l/2)+1;i++)
  20.     {
  21.         if(*l%i==0)
  22.         {
  23.         t+=i;
  24.         cout<<i<<" ";
  25.         }
  26.     }
  27.         if(t+1==*w) p++;
  28.  
  29.     cout<<'\t'<<"Suma: "<<t<<'\n';
  30.     delete l; delete w;
  31.     }
  32.     if (p==2) cout<<"TAK";
  33.     else cout<<"NIE";
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement