Nov 23, 2012 at 9:31pm UTC
#include <iostream>
using namespace std;
void main()
{
int array[6];
int temp=0;
for (int i=0; i<5; i++)
cin>>array[i];
for (int i=0; i<6; i++)
{
for (int j=0; j<5; j++)
{
if(array[j]>array[j+1])
{
temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}
}
for (int i=0;i<5; i++)
cout<<array[i];
}
Last edited on Nov 23, 2012 at 9:33pm UTC
Nov 23, 2012 at 9:40pm UTC
This is code the above in code tags! Yay!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <iostream>
using namespace std;
void main()
{
int array[6];
int temp=0;
for (int i=0; i<5; i++)
cin>>array[i];
for (int i=0; i<6; i++)
{
for (int j=0; j<5; j++)
{
if (array[j]>array[j+1])
{
temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}
}
for (int i=0;i<5; i++)
cout<<array[i];
}
Your main function must return an int. Like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#include <iostream>
using namespace std;
int main()
{
int array[6];
int temp=0;
for (int i=0; i<5; i++)
cin>>array[i];
for (int i=0; i<6; i++)
{
for (int j=0; j<5; j++)
{
if (array[j]>array[j+1])
{
temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}
}
for (int i=0;i<5; i++)
cout<<array[i];
return 0;
}
Last edited on Nov 23, 2012 at 9:42pm UTC