123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
#include<iostream> #include<stdlib.h> #include<time.h> #define l_max 6 void carico_t(int[]); void carico_r(int[]); void exchange(int[]); using namespace std; int main() { int vett[l_max], choice; std::cout<<"1) Fill the vector from the keyboard\n"; std::cout<<"2) Fill the vector with random numbers\n"; std::cin>>choice; switch(choice) { case(1): carico_t(vett); break; case(2): carico_r(vett); break; default: std::cout<<"Errore\n"; } exchange(vett); system("PAUSE"); return 0; } void carico_t(int vett[]) { std::cout<<"Insert vector elements.\n "; for(int i=0; i<l_max; i++) { std::cin>>vett[i]; } } void carico_r(int vett[]) { srand((unsigned int)time(0)); for(int i=0; i<l_max; i++) { vett[i]=rand(); } } void exchange(int vett[]) { int j=l_max-1, tmp=0; for(int i=0; i<(l_max)/2; i++) { tmp=vett[j]; vett[j]=vett[i]; vett[i]=tmp; j--; } std::cout<<"The vector with order reversed is\n"; for(int i=0; i<l_max; i++) { std::cout<<vett[i]<<std::endl; } }