SHARE
TWEET

Untitled

a guest Oct 9th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void parni(int unos, int niz[], int& rez, int& velicina)
  5.  
  6. {
  7.  
  8.     int k = 0;
  9.  
  10.     rez = 0;
  11.  
  12.     for (int i = 1; i < unos; i++)
  13.  
  14.     {
  15.  
  16.         if (i % 2 == 0)
  17.  
  18.         {
  19.  
  20.             rez += i;
  21.  
  22.             niz[k] = i;
  23.  
  24.             k++;
  25.  
  26.         }
  27.  
  28.     }
  29.  
  30.     velicina = k;
  31.  
  32. }
  33.  
  34. int main()
  35.  
  36. {
  37.  
  38.     int c, rj, velc;
  39.  
  40.     cin >> c;
  41.  
  42.     int *niz2 = new int[c/2 + 1];
  43.  
  44.     parni(c, niz2, rj, velc);
  45.  
  46.     cout << rj;
  47.  
  48.     cout << "\n";
  49.  
  50.     for (int i = 0; i < velc; i++)
  51.  
  52.     {
  53.  
  54.         cout << niz2[i] << ",";
  55.  
  56.     }
  57.     system("pause");
  58.     return 0;
  59.  
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top