#include <stdio.h>
#include<stdlib.h>
int main()
{
int AA[]={};
int size=0;
int temp,i,j,a;
/*------*/
printf("請輸入資料數量:");
scanf("%d",&size);
for (i=0;i<size;i++)
{
printf("請輸入第%d筆資料:",i+1);
scanf("%d",&AA[i]);
}
/*-----*/
system("cls");
printf("輸入資料為:");
for(i=0;i<size;i++)
{
printf("%d ",AA[i]);
}
printf("\n\n\n");
system("pause");
/*----*/
system("cls");
for(i=0;i<size;i++)
{
for(j=i+1;j<size;j++)
{
if (AA[i]>AA[j])
{
temp=AA[i];
AA[i]=AA[j];
AA[j]=temp;
}
}
}
printf("整理後由小到大為:");
for (i=0;i<size;i++)
{
printf("%d ",AA[i]);
}
printf("\n\n\n");
system("pause");
}
留言
張貼留言