#include<iostream.h>
#include<stdlib.h>
void input(int a[],int N)//隨機輸出10個數
{
for(int i=0;i<10;i++)
a[i]=rand()%100;
}
void bubblesort(int a[],int N)//排序
{
int temp;
for(int i=1;i<10;i++)
{
for(int j=0;j<10-i;j++)
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
void print (int a[],int N)//輸出
{
for(int i=0;i<N;i++)
cout<<a[i]<<" ";
cout<<endl;
}
const int n=10;
void main()
{
int num[n];
input(num,n);
cout<<"before sorted data:"<<endl;
print(num,n);
bubblesort(num,n);
cout<<"sorted data"<<endl;
print(num,n);
}