Advertisement
Guest User

Untitled

a guest
May 26th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <vector>
  3. #include <iostream>
  4.  
  5. /*Napisati program koji će primiti vector brojeva,
  6. i ispisati korisniku koji brojevi su parni, a koji neparni*/
  7. using namespace std;
  8. vector <int> numb;
  9. void vectInputAndCheck(vector <int> n1) {
  10.     //input
  11.    
  12.     for (int i = 0; i < 5; i++) {
  13.         int num;
  14.         cin >> num;
  15.         n1.push_back(num);
  16.     }
  17.  
  18.     //check
  19.    
  20.     cout << "Parni\n ";
  21.     for (size_t i = 0; i <n1.size(); i++) {
  22.         if (n1[i] % 2 == 0) {
  23.             cout << n1[i]<<endl;
  24.         }
  25.    
  26.     }
  27.     //check neparni
  28.     cout << "Neparni\n";
  29.     for (int i = 0; i < n1.size(); i++) {
  30.         if (n1[i] % 2 == 1) {
  31.             cout << n1[i]<<endl;
  32.         }
  33.     }
  34.    
  35. };
  36.  
  37.  
  38. int main() {
  39.  
  40.     cout << "Input nums\n";
  41.     vectInputAndCheck(numb);
  42.     system("Pause");
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement