程序代码:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i = 0;
int scores[10];
printf("输入成绩:");
while( i < 10 )//这个循环是用来输入的,不用在意while(),do-while(),for()的用法
{
scanf("%d", &scores[i]);//输入时用空格隔开
i++;
}
/*----------------------------------------*/
i = 0;
do{
if( scores[i] >= 90 )
{
printf("A\n");
}else if( scores[i] >= 80 && scores[i] <= 89 )
{
printf("B\n");
}else if( scores[i] >= 70 && scores[i] <= 79 )
{
printf("C\n");
}else if( scores[i] >= 60 && scores[i] <= 69 )
{
printf("D\n");
}else if( scores[i] < 60)
{
printf("E\n");
}
i++;
}while( i < 10 );
system("pause");
return 0;
}
/*这个是用的do-while()循环*/
程序代码:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i = 0;
int scores[10];
printf("输入成绩:");
while( i < 10 )//这个循环是用来输入的,不用在意while(),do-while(),for()的用法
{
scanf("%d", &scores[i]);//输入时用空格隔开
i++;
}
/*----------------------------------------*/
i = 0;
while( i < 10 )
{
if( scores[i] >= 90 )
{
printf("A\n");
}else if( scores[i] >= 80 && scores[i] <= 89 )
{
printf("B\n");
}else if( scores[i] >= 70 && scores[i] <= 79 )
{
printf("C\n");
}else if( scores[i] >= 60 && scores[i] <= 69 )
{
printf("D\n");
}else if( scores[i] < 60)
{
printf("E\n");
}
i++;
}
system("pause");
return 0;
}
/*这个是用的while()循环*/
程序代码:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i;
int scores[10];
printf("输入成绩:");
while( i < 10 )//这个循环是用来输入的,不用在意while(),do-while(),for()的用法
{
scanf("%d", &scores[i]);//输入时用空格隔开
i++;
}
/*----------------------------------------*/
for( i = 0; i < 10; i++)
{
if( scores[i] >= 90 )
{
printf("A\n");
}else if( scores[i] >= 80 && scores[i] <= 89 )
{
printf("B\n");
}else if( scores[i] >= 70 && scores[i] <= 79 )
{
printf("C\n");
}else if( scores[i] >= 60 && scores[i] <= 69 )
{
printf("D\n");
}else if( scores[i] < 60)
{
printf("E\n");
}
}
system("pause");
return 0;
}
/*这个是用的for()循环*/
我也是小白刚入门,大佬们请手下留情