Skip to main content

Posts

Showing posts with the label getch

example of random and randomize function in c++

example of random and randomize function in c++ void main() { randomize(); int k; int vett[90]; clrscr(); for (int i=0; i<90; i++) { do { vett=random(90)+1; k=0; while (vett!=vett[k]) k++; } while(k!=i); } cout<<"?????????"; cout<<"\n"; for (int j=0; j<90; j++) cout<<""<<vett[j]<<" "; int tab[91]; int h; int val; int u=0; for (int l=0; l<90; l++) { h=random(90-u); val=vett[h]; vett[h]=vett[90-u]; tab[val]=val; u++; } cout<<"\n"; cout<<"after ...........????"; cout<<"\n"; for (int y=1; y<91; y++) cout<<""<<tab[y]<<" "; getch(); }