#include <iostream>#include <time.h>#include <stdio.h>#include <stdlib.h>#define max 100using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char** argv) { srand(time(NULL)); int n , Chet = 0 ,notChet = 0 ,a[max]; cout<<"Size : "; cin>>n; for(int i = 0; i < n; i++) { a[i] = rand()%120+20; cout<<a[i]<<endl; if (a[i] %2 == 0) Chet++; else notChet++; } cout<<"Chet = "<<Chet<<", NotChet = "<<notChet; return 0;}
#include <time.h>
#include <stdlib.h>
int main()
{
srand(time(NULL));
int n;
int *a;
int n_max;
int n_index;
std::cout << "N: ";
std::cin >> n;
std::cout << "Source\n";
a = new int[n];
for (int i = 0; i<n; i++)
{
*(a + i) = rand() % 200 *(-1);
std::cout << *(a + i) << " ";
}
std::cout << "\n";
n_max = a[0];
for (int j = 0; j < n; j++)
{
if (*(a + j)>n_max)
{
n_max = *(a + j);
n_index = j;
}
}
std::cout << "\nMax: " <<n_max<<"\nIndex: "<<n_index+1<<std::endl;
return 0;
}