Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <cstdlib>
- #include <iostream>
- #include <ctime>
- #include <iomanip>
- #include <clocale>
- using namespace std;
- int main(int argc, char* argv[])
- {
- setlocale(LC_CTYPE, "rus");
- int n;
- cout<<"пиши циферки\n";
- cin>>n;
- srand(time(0));
- int* a=new int [n];
- for (int count = 0; count < n; count++)
- a[count] = (rand() % 50 );
- cout<<"Наш массив : ";
- for (int count = 0; count < n; count++)
- cout << a[count] << " ";
- cout << endl;
- int newsize=0;
- for(int i=0; i<n; i++)
- if(a[i]%2==0)
- a[newsize++]=a[i];
- cout<<"полученный массив: \n";
- for(int i=0; i<newsize; i++)
- cout << a[i] <<" ";
- system("pause") ;
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement