Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- #include <iomanip>
- using namespace std;
- int main()
- {
- while(true)
- {
- cout<<"Podaj dlugosc tablicy"<<endl;
- int lol;
- cin>>lol;
- const int x=lol;
- srand( time( NULL ) );
- int tab[x];
- int tablica[x];
- for(int k=0; k<x; k++)
- {
- tab[k]=rand()%101;
- cout<<setw(4)<<tab[k]<<" " ;
- }
- cout<<endl<<endl<<endl<<endl;
- for (int i=0; i<x; i++)
- {
- int suma=0;
- for(int j=0; j<i; j++)
- {
- if (tab[j]<tab[i])
- suma++;
- }
- tablica[i]=suma;
- }
- for(int a=0; a<x; a++)
- {
- cout<<setw(4)<<tablica[a]<<" " ;
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement