Autor Wiadomo¶ć
Ricko
PostWysłany: ¦ro 12:05, 15 Maj 2013    Temat postu: STUDIA: Sortowanie B±belkowe + Wypisanie Operacji

Cytat:
#include <cstdlib>
#include <iostream>
#include <ctime>

using namespace std;

int main(int argc, char *argv[])
{
int tab[15];
int i,j;

srand(time(0));
cout<<"Losujemy i wypisujemy tablice"<<endl;
for (int i=0;i<15;i++)
{
tab[i]=rand()%30;
cout<<tab[i]<<" ";
}
cout<<endl;

cout<<endl<<"Operacje sortowania"<<endl;

for (i=0;i<15;i++)
{

for (j=0;j<14;j++)
{
if (tab[j]>tab[j+1])
swap(tab[j],tab[j+1]);
}

for (int i=0;i<15;i++)
{
cout<<tab[i]<<" ";
}
cout<<endl;

}

system("PAUSE");
return EXIT_SUCCESS;
}

Powered by phpBB © 2001,2002 phpBB Group