Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int main()
- { srand(time(0));
- int ile, i, j, k, temp;
- cout << "\t\t PROGRAM SORTUJACY \n\n\n";
- cout << "\t\ Podaj iloma liczbami wypelnic tablice:";
- cin >> ile;
- int t[ile];
- for (i=0; i<ile; i++) t[i]=rand()%100;
- cout<<"\t Twoja tablica to: ";
- for (i=0; i<ile; i++) cout << t[i]<<" ";
- cout<<"\n\n";
- for (i=0; i<ile-1; i++)
- {
- for (j=0; j<ile-1; j++)
- {
- if (t[j]>=t[j+1])
- {
- temp=t[j];
- t[j]=t[j+1];
- t[j+1]=temp;
- }
- }
- cout << "\t"<< i+1<<")\t";
- for (k=0; k<ile; k++) cout <<t[k]<<" ";
- cout<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement