/*-------------------------------------------------------
【程序设计】
---------------------------------------------------------
题目:请编fun函数写程序,从键盘输入百分制成绩,要求输出
等级制成绩A、B、C、D。90~100分为A,80~89分为B,
60~79分为C,1~59分为D。不考虑小数,输入为整数,
输出为字符。
-------------------------------------------------------*/
#include <stdio.h>
void wwjt();
char fun (int n)
{
/**********Program**********/
char s;
switch(n){
case 10:
case 9:s='A';break;
case 8:s='B';break;
case 7:
case 6:s='C';break;
default:s='D';
}
return s;
/********** End **********/
}
void main()
{
int score,n;
char p;
scanf("%d",&score);
n=score/10;
p=fun(n);
printf("%c" , p);
wwjt();
}
void wwjt()
{
FILE *IN,*OUT;
int iIN,i;
char cOUT;
IN=fopen("in.dat","r");
if(IN==NULL)
{
printf("Please Verify The Currernt Dir..it May Be Changed");
}
OUT=fopen("out.dat","w");
if(OUT==NULL)
{
printf("Please Verify The Current Dir.. it May Be Changed");
}
for(i=0;i<5;i++)
{
fscanf(IN,"%d",&iIN);
cOUT=fun(iIN);
fprintf(OUT,"%c\n",cOUT);
}
fclose(IN);
fclose(OUT);
}