C语言 指针数组的题目,程序如下

2024-11-29 02:26:15
推荐回答(2个)
回答1:

#include

main()

{

float score[10];

float temp ;

int i,j;

float *q,*p = score;

printf("input 10 scores:\n");

for(i=0;i<10;i++)

scanf("%f",p++);

p = score;

printf("\n");

for(p = score;p

{

for(q=p+1;q

{

if(*p>*q)

{

temp = *p;

*p = *q;

*q = temp;

}

}

}

printf("the sorted numbers :\n");

for(p = score;p

printf("%5.2f,",*p++);

printf("\n");

}

回答2:

输出前加上 p=score;你这是太粗心了。