0
Program to arrange numbers in ascending order
using array or any method ( input 10 numbers)
3 Respuestas
+ 1
#include <iostream>
using namespace std;
int v[100],n,i,j,aux;
int main(){
cin>>n;
for(i=1;i<=n;i++)
cin>>v[i];
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
if(v[i]>v[j]){
aux=v[i];
v[i]=v[j];
v[j]=aux;
}
for(i=1;i<=n;i++)
cout<<v[i]<<" ";
return 0;
}
There you go :)
+ 1
easy solution :)
http://www.sololearn.com/app/cplusplus/playground/cg6Bl8bBFb3h/
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int array[10] = { 0, };
for (int i = 0; i < 10; ++i) {
cin >> array[i];
}
sort(array, array + 10);
for (int i = 0; i < 10; ++i) {
cout << array[i] << " ";
}
cout << "\n";
return 0;
}
0
thanks