0

I am new in programming. I have this problem in coding. i somehow have the idea but i could not simply do it in codes. can anyone add to complete my program.

The problem is I enter 10 numbers and i need to sort them ascendingly.

#include<iostream>
using namespace std;
int main()
{
int n[10],i;
cout<<"Enter 10 Numbers: ";
for(i=0;i<10;i++)
cin>>n;


system("pause>0");
}

I do not know the proceeding codes. can anyone help me to figure this out?
It would be a big help thanks in advance!

Edited:

Ok, just getting the set of numbers. Example, i entered 10 numbers

1
2
3
4
4
4
5
1
1
2

Output:
The set of number: {1,2,3,4,5}

how to get that?

Edited by jman2011: n/a

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by jman2011
0

Solution

# include <iostream>
using namespace std;
int main()
{
	int n[10];
	int i;
	int t;
	for( int i=0;i<10;i++) {
		cin>>n[i]; }
	for ( int i=0;i<9;i++) { 
		if(n[i]>n[i+1]) {
			t=n[i+1];
			n[i+1]=n[i];
		}
		cout<<n[i]<<" ";
	}
	return 0;
}
Votes + Comments
Please follow the site guidlines and only give help to those that show effort
0

Solution

# include <iostream>
using namespace std;
int main()
{
	int n[10];
	int i;
	int t;
	for( int i=0;i<10;i++) {
		cin>>n[i]; }
	for ( int i=0;i<9;i++) { 
		if(n[i]>n[i+1]) {
			t=n[i+1];
			n[i+1]=n[i];
		}
		cout<<n[i]<<" ";
	}
	return 0;
}

Bro! thanks!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.