|
发表于 2020-1-18 15:45:01
|
显示全部楼层
#include<stdio.h>
main()
{
int n,i,j,*temp,*p,num;
printf("input sum of the numbers\n");
scanf("%d",&n);
num=n;
printf("input numbers n<%d",num);
printf("\n");
for (i=0;i<n;i++) scanf("%d",p+i);
getchar();
for (i=0;i<n;i++)
for (j=0;j<n-i;j++)
if (*(p+j+1)<*(p+j))
{*temp=*(p+j);*(p+j)=*(p+j+1);*(p+j+1)=*temp;} /*冒泡交换*/
printf("the sort:\n");
for (i=0;i<n;i++) printf(" %d",*(p+i));
printf("\n");
getchar();
} |
|