以下是我的代码,运行不成功,求教是哪里出了问题?#include<stdio.h>int main(){ int i=0,j=0,s=0; int a[9]={22,54,32,65,865,347,85,23,34}; for(i=0;i<9;i++) printf("%d ",a[i]); printf("\n"); int temp=0; for(i=0;i<9;i++) {s=i; for(j=i+1;j<9;j++) { if (a[j]>a[i]) s=j; } if (s!=i) { temp=a[s]; a[s]=a[i]; a[i]=temp; } } for(i=0;i<9;i++) { printf("%d ",a[i]); } printf("1"); return 0; }
#include <stdio.h>
int main()
{
int i = 0, j = 0, s = 0;
int a[9] = { 22, 54, 32, 65, 865, 347, 85, 23, 34 };
for (i = 0; i < 9; i++)
printf("%d ", a[i]);
printf("\n");
int temp = 0;
for (i = 0; i < 9; i++)
{
s = i;
for (j = i + 1; j < 9; j++)
{
if (a[j] > a[s])
s = j;
}
if (s != i)
{
temp = a[s];
a[s] = a[i];
a[i] = temp;
}
}
for (i = 0; i < 9; i++)
{
printf("%d ", a[i]);
}
printf("1");
return 0;
}
本回答被提问者采纳