c语言编译错误
#include<stdio.h>intmain(){inta,b,c,d,e,f,g;chargrade(intx);scanf("%d\n%d\n%d\n%d\n%d...
#include<stdio.h>int main(){int a,b,c,d,e,f,g;char grade(int x);scanf("%d\n%d\n%d\n%d\n%d\n%d\n%d",&a,&b,&c,&d,&e,&f,&g);printf("%s",grade(a));printf("%s",grade(b));printf("%s",grade(c));printf("%s",grade(d));printf("%s",grade(e));printf("%s",grade(f));printf("%s",grade(g));}char grade(int x){ int t; if(x>=90) t=1; else if(x<90&&x>=80)t=2; else if(x<80&&x>=70)t=3; else if(x<70&&x>=60)t=4; else if(x<60&&x>=0)t=5; else t=6; switch(t){case 1:printf("Excellent\n");break; case 2:printf("Good\n");break; case 3:printf("Average\n");break; case 4:printf("Pass\n");break; case 5:printf("Failing\n");break; case 6:printf("Error\n");break;}}
展开
展开全部
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
int a,b,c,d,e,f,g;
char* grade(int x);
scanf("%d\n%d\n%d\n%d\n%d\n%d\n%d",&a,&b,&c,&d,&e,&f,&g);
printf("%s\n",grade(a));
printf("%s\n",grade(b));
printf("%s\n",grade(c));
printf("%s\n",grade(d));
printf("%s\n",grade(e));
printf("%s\n",grade(f));
printf("%s\n",grade(g));
return 0;
}
char* grade(int x){
int t;
char *buff=new char[10+1];;
memset(buff,0x00,sizeof(buff));
if(x>=90) t=1;
else if(x<90&&x>=80)t=2;
else if(x<80&&x>=70)t=3;
else if(x<70&&x>=60)t=4;
else if(x<60&&x>=0)t=5;
else t=6;
switch(t){
case 1:strcpy(buff, "Excellent");break;
case 2:strcpy(buff, "Good");break;
case 3:strcpy(buff, "Average");break;
case 4:strcpy(buff, "Pass");break;
case 5:strcpy(buff, "Failing");break;
case 6:strcpy(buff, "Error");break;
}
return buff;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询