#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <iostream> using namespace std; int main(int argc, char* argv[]) { int arr[10]; cout << "input elements " << endl; for ( int i= 0; i < 10; i++ ) cin >> arr[i]; int max=-9999; int min=9999; cout << "Massiv " << endl; for ( int o= 0; o < 10; o++ ) cout << arr[o] <<" "; cout << ""<<endl; for ( int l= 0; l < 10; l++ ) if((arr[l]>max) and (arr[l]<0 ) ) max =arr[l];
cout << "Max from negatives is: " <<" "; cout << max << endl; for ( int z= 0; z < 10; z++ ) if((arr[z]<min)and(arr[z]>=0)) min =arr[z]; cout << "Min from positives is: " <<" "; cout << min << endl;
int gmax,gmax2; gmax=arr[1]; gmax2=arr[2]; for (int l=2;l<10;l++) if(arr[l]>gmax){ gmax2=gmax;gmax=arr[l]; }else if(arr[l]>gmax2)gmax2=arr[l]; cout << "Second greatest element is: " <<" "; cout << gmax2<< endl; }
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <cstdlib>
using namespace std;
const int SIZE = 20;
int arr[SIZE] = { -1, 1, 5, 2, -4, 0, 7, -2, 5, -9, 3,6,-9,0,-4,4,6,2,13,5 };
int main()
{
cout << "new Array:" << std::endl;
copy(arr, arr + SIZE, std::ostream_iterator<int>(std::cout, " "));
cout << std::endl;
int first= arr[0];
for (int k=0;k<SIZE-2;k++)
arr [k]=arr[k+1];
arr[SIZE-1]=first;
cout << "new Array:" << std::endl;
copy(arr, arr + SIZE, std::ostream_iterator<int>(std::cout, " "));
cout << std::endl;
system("pause");
return 0;}
с в) долго думал
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
int arr[10];
cout << "input elements " << endl;
for ( int i= 0; i < 10; i++ )
cin >> arr[i];
int max=-9999;
int min=9999;
cout << "Massiv " << endl;
for ( int o= 0; o < 10; o++ )
cout << arr[o] <<" ";
cout << ""<<endl;
for ( int l= 0; l < 10; l++ )
if((arr[l]>max) and (arr[l]<0 ) )
max =arr[l];
cout << "Max from negatives is: " <<" ";
cout << max << endl;
for ( int z= 0; z < 10; z++ )
if((arr[z]<min)and(arr[z]>=0)) min =arr[z];
cout << "Min from positives is: " <<" ";
cout << min << endl;
int gmax,gmax2;
gmax=arr[1];
gmax2=arr[2];
for (int l=2;l<10;l++)
if(arr[l]>gmax){
gmax2=gmax;gmax=arr[l]; }else if(arr[l]>gmax2)gmax2=arr[l];
cout << "Second greatest element is: " <<" ";
cout << gmax2<< endl;
}