|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
#pragma warning(disable : 4996
#include<string.h>
struct stu {
const char* name;
int ching;
int shux;
int ying;
}stu1 = {"小红",89,94,88};
char m[] = "小红";
char k[] = "小明";
char b[] = "小樱";
char (*g(char o[10]))();
int main()
{
char l[10];
printf("请输入你要查看学生成绩的姓名:");
scanf("%s", &l);
g(l);
}
char hong();
char hong()
{
printf("%s的语文成绩为%d\n数学成绩为%d\n英语成绩为%d\n", stu1.name, stu1.ching, stu1.shux, stu1.ying);
}
char ming();
char ming()
{
struct stu stu2;
stu2.name="小明";
stu2.ching=98;
stu2.shux=94;
stu2.ying=97;
printf("%s的语文成绩为%d\n数学成绩为%d\n英语成绩为%d\n", stu2.name, stu2.ching, stu2.shux, stu2.ying);
}
char ying();
char ying()
{
struct stu stu3;
stu3.name="小樱";
stu3.ching=94;
stu3.shux=86;
stu3.ying=96;
printf("%s的语文成绩为%d\n数学成绩为%d\n英语成绩为%d\n", stu3.name, stu3.ching, stu3.shux, stu3.ying);
}
char (*g( char o[10]))()
{
char (*mm)(),(*kk)(),(*ll)();
mm=hong;
kk=ming;
ll=ying;
if (strcmp(o,m)==0)
return mm;
else if (strcmp(o,k)==0)
return kk;
else if (strcmp(o,b)==0)
return ll;
else
printf("输出错误信息 本次帮助结束\n");
}
将main函数里的g(l);改为g(l)();就正常了,原因,涵数自己没写完整,下次注意点,兄弟。哈哈哈哈
|
|