Advertisement
Guest User

Untitled

a guest
May 29th, 2012
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <ctime>
  5. #include <iomanip>
  6. #include <clocale>
  7. using namespace std;
  8.  
  9. int main(int argc, char* argv[])
  10. {
  11.     setlocale(LC_CTYPE, "rus");
  12.    
  13.     int n;
  14.     cout<<"пиши циферки\n";
  15.     cin>>n;
  16.     srand(time(0));
  17.     int* a=new int [n];
  18.     for (int count = 0; count < n; count++)
  19.     a[count] = (rand() % 50 );
  20.     cout<<"Наш массив :  ";
  21.     for (int count = 0; count < n; count++)
  22.     cout  << a[count] << "  ";
  23.     cout << endl;
  24.     int newsize=0;
  25.     for(int i=0; i<n; i++)
  26.     if(a[i]%2==0)
  27.     a[newsize++]=a[i];
  28.    
  29.     cout<<"полученный массив:  \n";
  30.     for(int i=0; i<newsize; i++)
  31.     cout << a[i] <<"   ";  
  32.    
  33.  
  34.  
  35.  
  36.     system("pause") ;
  37.     return 0 ;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement