gagiD

Funkcije

Apr 25th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int f(int niz[])
  5. {
  6.  
  7.    for (int i=0; i<niz[i]; i++)
  8.    {
  9.      if ((niz[i]) % 2 != 0)
  10.         {
  11.           niz[i] = niz[i] * 3;
  12.  
  13.         }
  14.      if ((niz[i]) % 2 == 0)
  15.         {
  16.           niz[i] = niz[i] * 2;
  17.         }
  18.         }
  19.         int i = 0;
  20.     int MAX = niz[i];
  21.     for (int i = 0; i<niz[i]; i++)
  22.                 {
  23.           if (niz[i] >= MAX)
  24.             {
  25.               MAX = niz[i];
  26.             }
  27.         }
  28.      return MAX;
  29. }
  30.  
  31. void g( int x ) {
  32.   for ( int i = 1 ; i <= x ; i++ ) {
  33.     cout<<x<<endl;;
  34.   }
  35. }
  36.  
  37. int main()
  38. {
  39.         int niz[3];
  40.         cout << "Unesite 3 broja: " << endl;
  41.         cin >> niz[0] >> niz[1] >> niz[2];
  42.         int rez = f(niz);
  43.  
  44.         g(rez);
  45.  
  46.         return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment