#include <vector>
#include <algorithm>
using namespace std;
void error();
int main()
{
int i,l,number,sizea;
int temp = 0;
vector<int> scores;
vector<int>::iterator sortedunique;
cout << "Masukkan jumlah data: ";
cin>>number;
if(number<1)
error();
for(l=1;l<=number;l++)
{
cout << "Masukkan nilai data ke-"<<l<<": ";
cin >> temp;
scores.push_back (temp);
}
sort (scores.begin(), scores.end());
sizea = scores.size();
for (i = 0; i < sizea; i++)
{
for (i = 0; i < sizea; i++)
{
cout<<scores[i]<<" ";
}
cout<<endl;
}
cout << "Data diurutkan sebagai berikut: ";
for (i = 0; i < sizea; i++)
{
cout << scores[i] << " ";
}
cout << endl;
cin.get();cin.get();
}
void error()
{
cout<<"Masukan nilai tidak valid"<<endl;
main();
}
0 Comments