pierdziadek

#6 - Informatyka - 16.03.2020

Mar 16th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int nwdwynik[30];
  6. long suma;
  7.  
  8. int nwd(int a, int b) {
  9.     while(a!=b)
  10.         if(a>b) a-=b;
  11.         else b-=a;
  12.     return a;
  13. }
  14.  
  15. int main() {
  16.     int dane[60] = {24023, 30435, 5687, 12034, 7607, 3590, 4289, 13001, 7797, 13525, 14713, 6258, 10309, 22595, 14549, 22702, 15079, 31650, 15663, 32637, 11560, 27158, 13930, 2371, 26027, 7242, 29912, 5662, 4329, 9825, 12123, 26487, 30839, 16944, 13515, 23511, 24456, 18858, 19608, 23804, 2226, 13723, 2737, 29741, 18677, 29850, 6820, 30922, 19449, 11832, 17926, 3367, 28055, 18046, 14869, 23962, 19611, 13719, 20636, 21971};
  17.     for(int i = 0; i < 58; i=i+2) {
  18.         nwdwynik[i/2] = nwd(dane[i], dane[i+1]);
  19.     }
  20.     for(int i = 0; i < 29; i++) {
  21.         suma = suma + nwdwynik[i];
  22.     }
  23.     cout << suma;
  24.  
  25.  
  26.  
  27.     return 0;
  28. }
Add Comment
Please, Sign In to add comment