ZivkicaI

SARA KORCH

May 15th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                               Online C++ Compiler.
  4.                Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.    int niza[100],nizaP[100],nizaN[100],i,n,brElemP=0,brElemN=0;
  16.    cout<<"Vnesi broj na elementi vo nizata"<<endl;
  17.    cin>>n;
  18.    for(i=0;i<n;i++)
  19.    {
  20.        cin>>niza[i];
  21.    }
  22.    int j=0;
  23.    int k=0;
  24.    for(i=0;i<n;i++)
  25.    {
  26.        if(niza[i]%2==0)
  27.        {
  28.            nizaP[j]=niza[i];
  29.            j++;
  30.            brElemP++;
  31.        }
  32.        else
  33.        {
  34.            nizaN[k]=niza[i];
  35.            k++;
  36.            brElemN++;
  37.        }
  38.        
  39.    }
  40.    
  41.    for(j=0;j<brElemP;j++)
  42.    {
  43.       cout<<nizaP[j]<<",";
  44.      
  45.        
  46.    }
  47.    cout<<endl;
  48.    for(k=0;k<brElemN;k++)
  49.    {
  50.       cout<<nizaN[k]<<",";
  51.      
  52.        
  53.    }
  54.    
  55.   return 0;
  56.    
  57. }
Advertisement
Add Comment
Please, Sign In to add comment