Advertisement
Guest User

ALINA M. ODKRYŁA SPOSÓB JAK UJEBAĆ WSZYSTKICH, ZOBACZ JAK

a guest
Nov 14th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. #include <iomanip>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     while(true)
  10.     {
  11.         cout<<"Podaj dlugosc tablicy"<<endl;
  12.         int lol;
  13.         cin>>lol;
  14.         const int x=lol;
  15.         srand( time( NULL ) );
  16.         int tab[x];
  17.         int tablica[x];
  18.         for(int k=0; k<x; k++)
  19.         {
  20.             tab[k]=rand()%101;
  21.             cout<<setw(4)<<tab[k]<<"  " ;
  22.         }
  23.         cout<<endl<<endl<<endl<<endl;
  24.         for (int i=0; i<x; i++)
  25.         {
  26.             int suma=0;
  27.             for(int j=0; j<i; j++)
  28.             {
  29.                 if (tab[j]<tab[i])
  30.                     suma++;
  31.             }
  32.             tablica[i]=suma;
  33.         }
  34.  
  35.         for(int a=0; a<x; a++)
  36.         {
  37.  
  38.             cout<<setw(4)<<tablica[a]<<"  " ;
  39.         }
  40.         cout<<endl;
  41.     }
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement