第1个回答 2011-03-23
#include <stdio.h>
main()
{
int score=0;
do
{
printf("请输入成绩(负数退出):");
scanf( "%d",& score);
if( score < 0) exit(0);
if( score > 100)
{
printf("Input error;\r\n");
continue;
}
switch( (int)(score / 10))
{
case 10:
case 9: printf("super\r\n");
break;
case 8: printf("good\r\n");
break;
case 7: printf("OK\r\n");
break;
case 6: printf("pass\r\n");
break;
default:printf("no good\r\n");
break;
}
}while( 1 );
}
第2个回答 2011-03-24
int main(void)
{
int score[100];
int * ps=score;
char *pc[]={"super","good","OK","pass","no good"};
int i,k,j;
k=1;
i=0;
printf("Please input your score:\n");
while(k)
{
scanf("%d",ps+i);
if(*(ps+i)<0)
{
k=0;
}
else if(*(ps+i)>100)
{
printf("input error");
continue;
}
i++;
}
for(j=0;j<i-1;j++)
{
if(*(score+j)>=90)
k=0;
else if(*(score+j)>=80)
k=1;
else if(*(score+j)>=70)
k=2;
else if(*(score+j)>=60)
k=3;
else
k=4;
printf("%d.%d \"%s\"\n",j+1,*(ps+j),*(pc+k));
}
}