代码出现这个是啥意思
应该怎么改呢#include<stdio.h>#include<stdlib.h>#include<string.h>char*swtgrade(int*score){c...
应该怎么改呢
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *swtgrade(int *score)
{
char g[10];
switch(*score/10)
{
case 1:
case 2:
case 3:
case 4:
case 5:
strcpy(&g[10],"不及格");
case 6:
strcpy(&g[10],"及格");
case 7:
strcpy(&g[10],"中等");
case 8:
strcpy(&g[10],"良好");
case 9:
case 10:
strcpy(&g[10],"优秀");
}
return &g[10];
}
int main()
{
int x,score;
char i;
x=1;
while(x<=6)
{
printf("成绩:");
scanf("%d",&score);
printf("等级:%s",i=*swtgrade(&score));
x++;
}
} 展开
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *swtgrade(int *score)
{
char g[10];
switch(*score/10)
{
case 1:
case 2:
case 3:
case 4:
case 5:
strcpy(&g[10],"不及格");
case 6:
strcpy(&g[10],"及格");
case 7:
strcpy(&g[10],"中等");
case 8:
strcpy(&g[10],"良好");
case 9:
case 10:
strcpy(&g[10],"优秀");
}
return &g[10];
}
int main()
{
int x,score;
char i;
x=1;
while(x<=6)
{
printf("成绩:");
scanf("%d",&score);
printf("等级:%s",i=*swtgrade(&score));
x++;
}
} 展开
2019-05-30
展开全部
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char *swtgrade(int score)
{
static char g[10] = "";
switch (score / 10)
{
case 1:
case 2:
case 3:
case 4:
case 5:
strcpy(g, "不及格");
break;
case 6:
strcpy(g, "及格");
break;
case 7:
strcpy(g, "中等");
break;
case 8:
strcpy(g, "良好");
break;
case 9:
case 10:
strcpy(g, "优秀");
break;
}
return g;
}
int main()
{
int x, score;
char *i;
x = 1;
while (x <= 6)
{
printf("成绩:");
scanf_s("%d", &score);
i = swtgrade(score);
printf("等级:%s\n",i);
x++;
}
}
附带一个网站:函数返回值
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你代码中有个符号用的不对,建议检查一下变量g附近的运算符
追问
应该怎么改呢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询