鱼C论坛

 找回密码
 立即注册
查看: 1762|回复: 11

[已解决]请求大佬们救救孩子!程序今晚就要交了,运行到选择试题之后程序却结束了

[复制链接]
发表于 2021-6-22 21:53:54 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include<stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct Test)

void getInput(struct Test *test);
int put_test(int m);
void testing();
int total(void);
void remain();
void main();

struct Test
{
        char que[100];
        char answer1[100];
        char answer2[100];
        char answer3[100];
        char answer4[100];
        char ture[100];
        struct Test *next;
};
struct Test *head;

int put_test(int m)
{
        struct Test *test=NULL;
        FILE *fp;
        if((fp=fopen("test1.txt","r"))==NULL)
        {
                printf("打开文件失败!\n");
                exit(0);
        }
        char ch,ture_answer[5];
        int i,n=0,now,py;
        do
        {
                py=1;
                ch=fgetc(fp);
                for(i=0;ch!='\n'&&ch!=-1;i++)
                {
                        py++;
                        ch=fgetc(fp);
                }
                n++;
                if(n==m)
                {
                        if(test==NULL)
                        {
                                test=(struct Test *)malloc(LEN);
                                head=test;
                                test->next=NULL;
                        }
                        else
                        {
                                test->next=test;
                                test=(struct Test *)malloc(LEN);
                                test->next=NULL;
                        }
                now=ftell(fp);
                fseek(fp,(now-py-1),0);
                fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
                fseek(fp,now+1,0);
                *test->ture=ture_answer[0];
                break;
                }
        }while(!feof(fp));
        fclose(fp);
        return 0;
}

void testing()
{
        int n,o_n,m,i,yes=0,no=0;
        char user_answer[2];
        struct Test *test;
        printf("请输入您想答题的数目:\n");
        scanf("%d",&n);
        o_n=total();
        if(n>o_n||n<0)
        {
                printf("输入错误!");
                testing();
        }
        for(i=0;i<n;i++)
        {
                do
                {
                        m=rand();
                }while(m<=0&&m>o_n);
                put_test(m);
                test=head;
                printf("第%d题:\n",i+1);
                printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
                scanf("%s",&user_answer);
                if(user_answer[0]==*test->ture)
                {
                        printf("答案正确!");
                        yes++;
                }
                else
                {
                        printf("答案错误!\n正确答案是:%s\n",test->ture);
                        no++;
                }
        }
                test=head;
                do
                {
                        head=test->next;
                        free(test);
                        test=head;
                }while(test!=NULL);
        printf("测试结束!\n您的得分是:%d\n正确率:%.2f%%\n",yes,(float)yes/n*100);
        remain();
}

int total(void)
{
        FILE *fp;
        if((fp=fopen("test1.txt","r"))==NULL)
        {
                printf("打开文件失败!");
                exit(0);
        }
        int n=0;
        char c;
        c=fgetc(fp);
        do
        {        
                if(c=='\n')
                        n++;
                c=fgetc(fp);
        }while(!feof(fp));
        return n;
}

void getInput(struct Test *test)
{
        int i,n;
        printf("你将输入多少道试题?\n");
        scanf("%d",&n);
        FILE *fp;
        if((fp=fopen("test1.txt","a"))==NULL)
        {
                printf("打开文件错误!\n");
                exit(0);
        }
        test=(struct Test *)malloc(LEN);
        for(i=1;i<=n;i++)
        {
                printf("题目:");
                scanf("%s",test->que);
                printf("A.");
                scanf("%s",test->answer1);
                printf("B.");
                scanf("%s",test->answer2);
                printf("C.");
                scanf("%s",test->answer3);
                printf("D.");
                scanf("%s",test->answer4);
                printf("正确答案:");
                scanf("%s",test->ture);

                fputs(test->que,fp);
                fputs(" A.",fp);
                fputs(test->answer1,fp);
                fputs(" B.",fp);
                fputs(test->answer2,fp);
                fputs(" C.",fp);
                fputs(test->answer3,fp);
                fputs(" D.",fp);
                fputs(test->answer4,fp);
                fputs(" 正确答案:",fp);
                fputs(test->ture,fp);
                fputc('\n',fp);
        }
        fclose(fp);
        free(test);
        remain();
}

void remain()
{
        int flag;
        printf("1.返回主菜单\n");
        printf("2.退出程序\n");
        printf("请输入你的选择:\n");
        scanf("%d",&flag);
        switch(flag)
        {
        case 1: main(); break;
        case 2: exit(0);break;
        default:printf("输入错误!");
        }
}

void main()
{
        struct Test test;
        int flag;
        printf("--------单项选择题标准化考试系统--------\n");
        printf("1.录入试题\n");
        printf("2.自主测试\n");
        printf("3.退出程序\n");
        printf("请输入你的选择:\n");
        scanf("%d",&flag);
        switch(flag)
        {
        case 1: getInput(&test); break;
        case 2: testing(); break;
        case 3: exit(0); break;
        default:printf("输入错误!\n");
        }
}
最佳答案
2021-6-22 23:38:12
小菜鸡溜溜达 发表于 2021-6-22 23:09
运行以后结果成这样:
--------单项选择题标准化考试系统--------
1.录入试题

如果你的编译器什么提示也没有的话,一定要换一个好点的
main.c:5:22: warning: ‘struct Test’ declared inside parameter list will not be visible outside of this definition or declaration
    5 | void getInput(struct Test *test);
      |                      ^~~~
main.c: In function ‘put_test’:
main.c:61:29: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘char (*)[100]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                            ~^            ~~~~~~~~~~
      |                             |            |
      |                             char *       char (*)[100]
main.c:61:31: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘char (*)[100]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                              ~^                     ~~~~~~~~~~~~~~
      |                               |                     |
      |                               char *                char (*)[100]
main.c:61:33: warning: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘char (*)[100]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                                ~^                                  ~~~~~~~~~~~~~~
      |                                 |                                  |
      |                                 char *                             char (*)[100]
main.c:61:35: warning: format ‘%s’ expects argument of type ‘char *’, but argument 6 has type ‘char (*)[100]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                                  ~^                                               ~~~~~~~~~~~~~~
      |                                   |                                               |
      |                                   char *                                          char (*)[100]
main.c:61:37: warning: format ‘%s’ expects argument of type ‘char *’, but argument 7 has type ‘char (*)[100]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                                    ~^                                                            ~~~~~~~~~~~~~~
      |                                     |                                                            |
      |                                     char *                                                       char (*)[100]
main.c:61:39: warning: format ‘%s’ expects argument of type ‘char *’, but argument 8 has type ‘char (*)[5]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                                      ~^                                                                         ~~~~~~~~~~~~
      |                                       |                                                                         |
      |                                       char *                                                                    char (*)[5]
main.c: In function ‘testing’:
main.c:93:26: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]
   93 |                 printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
      |                         ~^                                    ~~~~~~~~~~
      |                          |                                    |
      |                          char *                               int
      |                         %d
main.c:93:30: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=]
   93 |                 printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
      |                             ~^                                           ~~~~~~~~~~~~~~
      |                              |                                           |
      |                              char *                                      int
      |                             %d
main.c:93:34: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Wformat=]
   93 |                 printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
      |                                 ~^                                                      ~~~~~~~~~~~~~~
      |                                  |                                                      |
      |                                  char *                                                 int
      |                                 %d
main.c:93:38: warning: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘int’ [-Wformat=]
   93 |                 printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
      |                                     ~^                                                                 ~~~~~~~~~~~~~~
      |                                      |                                                                 |
      |                                      char *                                                            int
      |                                     %d
main.c:93:42: warning: format ‘%s’ expects argument of type ‘char *’, but argument 6 has type ‘int’ [-Wformat=]
   93 |                 printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
      |                                         ~^                                                                            ~~~~~~~~~~~~~~
      |                                          |                                                                            |
      |                                          char *                                                                       int
      |                                         %d
main.c:94:25: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[2]’ [-Wformat=]
   94 |                 scanf("%s",&user_answer);
      |                        ~^  ~~~~~~~~~~~~
      |                         |  |
      |                         |  char (*)[2]
      |                         char *
main.c: At top level:
main.c:137:6: error: conflicting types for ‘getInput’; have ‘void(struct Test *)’
  137 | void getInput(struct Test *test)
      |      ^~~~~~~~
main.c:5:6: note: previous declaration of ‘getInput’ with type ‘void(struct Test *)’
    5 | void getInput(struct Test *test);
      |      ^~~~~~~~
main.c:197:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
  197 | void main()
      |      ^~~~
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-6-22 22:25:52 | 显示全部楼层
具体描述一下你这个程序的问题
我需要 这个程序的每一步操作,直到出现问题
首先运行这个程序,然后输入 1 ?
然后输入什么?
反正就是你一直输入,直到发现了明显的问题为止
我要全部的这些输入
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-6-22 22:42:39 | 显示全部楼层
加油
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-6-22 23:02:52 | 显示全部楼层
加油
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-6-22 23:06:53 | 显示全部楼层
人造人 发表于 2021-6-22 22:25
具体描述一下你这个程序的问题
我需要 这个程序的每一步操作,直到出现问题
首先运行这个程序,然后输入  ...

输入完1之后开始设置几个题目,输入题目的个数之后输入题目的内容以及选项、正确答案;第二个程序是自主测试,选择自主测试之后输入你想测试题目的题号
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-6-22 23:07:28 | 显示全部楼层

哈哈哈哈?喵喵喵?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-6-22 23:09:52 | 显示全部楼层
人造人 发表于 2021-6-22 22:25
具体描述一下你这个程序的问题
我需要 这个程序的每一步操作,直到出现问题
首先运行这个程序,然后输入  ...

运行以后结果成这样:
--------单项选择题标准化考试系统--------
1.录入试题
2.自主测试
3.退出程序
请输入你的选择:
1
你将输入多少道试题?
2
题目:2
A.1
B.1
C.2
D.3
正确答案:C
题目:3
A.1
B.23
C.3
D.4
正确答案:C
1.返回主菜单
2.退出程序
请输入你的选择:
2

--------------------------------
Process exited after 20.65 seconds with return value 0
请按任意键继续. . .
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-6-22 23:38:12 | 显示全部楼层    本楼为最佳答案   
小菜鸡溜溜达 发表于 2021-6-22 23:09
运行以后结果成这样:
--------单项选择题标准化考试系统--------
1.录入试题

如果你的编译器什么提示也没有的话,一定要换一个好点的
main.c:5:22: warning: ‘struct Test’ declared inside parameter list will not be visible outside of this definition or declaration
    5 | void getInput(struct Test *test);
      |                      ^~~~
main.c: In function ‘put_test’:
main.c:61:29: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘char (*)[100]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                            ~^            ~~~~~~~~~~
      |                             |            |
      |                             char *       char (*)[100]
main.c:61:31: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘char (*)[100]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                              ~^                     ~~~~~~~~~~~~~~
      |                               |                     |
      |                               char *                char (*)[100]
main.c:61:33: warning: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘char (*)[100]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                                ~^                                  ~~~~~~~~~~~~~~
      |                                 |                                  |
      |                                 char *                             char (*)[100]
main.c:61:35: warning: format ‘%s’ expects argument of type ‘char *’, but argument 6 has type ‘char (*)[100]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                                  ~^                                               ~~~~~~~~~~~~~~
      |                                   |                                               |
      |                                   char *                                          char (*)[100]
main.c:61:37: warning: format ‘%s’ expects argument of type ‘char *’, but argument 7 has type ‘char (*)[100]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                                    ~^                                                            ~~~~~~~~~~~~~~
      |                                     |                                                            |
      |                                     char *                                                       char (*)[100]
main.c:61:39: warning: format ‘%s’ expects argument of type ‘char *’, but argument 8 has type ‘char (*)[5]’ [-Wformat=]
   61 |                 fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
      |                                      ~^                                                                         ~~~~~~~~~~~~
      |                                       |                                                                         |
      |                                       char *                                                                    char (*)[5]
main.c: In function ‘testing’:
main.c:93:26: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]
   93 |                 printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
      |                         ~^                                    ~~~~~~~~~~
      |                          |                                    |
      |                          char *                               int
      |                         %d
main.c:93:30: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=]
   93 |                 printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
      |                             ~^                                           ~~~~~~~~~~~~~~
      |                              |                                           |
      |                              char *                                      int
      |                             %d
main.c:93:34: warning: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Wformat=]
   93 |                 printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
      |                                 ~^                                                      ~~~~~~~~~~~~~~
      |                                  |                                                      |
      |                                  char *                                                 int
      |                                 %d
main.c:93:38: warning: format ‘%s’ expects argument of type ‘char *’, but argument 5 has type ‘int’ [-Wformat=]
   93 |                 printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
      |                                     ~^                                                                 ~~~~~~~~~~~~~~
      |                                      |                                                                 |
      |                                      char *                                                            int
      |                                     %d
main.c:93:42: warning: format ‘%s’ expects argument of type ‘char *’, but argument 6 has type ‘int’ [-Wformat=]
   93 |                 printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
      |                                         ~^                                                                            ~~~~~~~~~~~~~~
      |                                          |                                                                            |
      |                                          char *                                                                       int
      |                                         %d
main.c:94:25: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[2]’ [-Wformat=]
   94 |                 scanf("%s",&user_answer);
      |                        ~^  ~~~~~~~~~~~~
      |                         |  |
      |                         |  char (*)[2]
      |                         char *
main.c: At top level:
main.c:137:6: error: conflicting types for ‘getInput’; have ‘void(struct Test *)’
  137 | void getInput(struct Test *test)
      |      ^~~~~~~~
main.c:5:6: note: previous declaration of ‘getInput’ with type ‘void(struct Test *)’
    5 | void getInput(struct Test *test);
      |      ^~~~~~~~
main.c:197:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
  197 | void main()
      |      ^~~~
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-6-22 23:38:56 | 显示全部楼层
#include<stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct Test)

//void getInput(struct Test *test);
int put_test(int m);
void testing();
int total(void);
void remain();
//void main();
int main(void);

struct Test
{
    char que[100];
    char answer1[100];
    char answer2[100];
    char answer3[100];
    char answer4[100];
    char ture[100];
    struct Test *next;
};
struct Test *head;

void getInput(struct Test *test);

int put_test(int m)
{
    struct Test *test=NULL;
    FILE *fp;
    if((fp=fopen("test1.txt","r"))==NULL)
    {
        printf("打开文件失败!\n");
        exit(0);
    }
    char ch,ture_answer[5];
    int i,n=0,now,py;
    do
    {
        py=1;
        ch=fgetc(fp);
        for(i=0;ch!='\n'&&ch!=-1;i++)
        {
            py++;
            ch=fgetc(fp);
        }
        n++;
        if(n==m)
        {
            if(test==NULL)
            {
                test=(struct Test *)malloc(LEN);
                head=test;
                test->next=NULL;
            }
            else
            {
                test->next=test;
                test=(struct Test *)malloc(LEN);
                test->next=NULL;
            }
            now=ftell(fp);
            fseek(fp,(now-py-1),0);
            //fscanf(fp,"%s%s%s%s%s%s",&test->que,&test->answer1,&test->answer2,&test->answer3,&test->answer4,&ture_answer);
            fscanf(fp,"%s%s%s%s%s%s",test->que,test->answer1,test->answer2,test->answer3,test->answer4,ture_answer);
            fseek(fp,now+1,0);
            *test->ture=ture_answer[0];
            break;
        }
    }while(!feof(fp));
    fclose(fp);
    return 0;
}

void testing()
{
    int n,o_n,m,i,yes=0,no=0;
    char user_answer[2];
    struct Test *test;
    printf("请输入您想答题的数目:\n");
    scanf("%d",&n);
    o_n=total();
    if(n>o_n||n<0)
    {
        printf("输入错误!");
        testing();
    }
    for(i=0;i<n;i++)
    {
        do
        {
            m=rand();
        }while(m<=0&&m>o_n);
        put_test(m);
        test=head;
        printf("第%d题:\n",i+1);
        //printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",*test->que,*test->answer1,*test->answer2,*test->answer3,*test->answer4);
        printf("%s\n%s\n%s\n%s\n%s\n请输入您的答案:",test->que,test->answer1,test->answer2,test->answer3,test->answer4);
        //scanf("%s",&user_answer);
        scanf("%s",user_answer);
        if(user_answer[0]==*test->ture)
        {
            printf("答案正确!");
            yes++;
        }
        else
        {
            printf("答案错误!\n正确答案是:%s\n",test->ture);
            no++;
        }
    }
    test=head;
    do
    {
        head=test->next;
        free(test);
        test=head;
    }while(test!=NULL);
    printf("测试结束!\n您的得分是:%d\n正确率:%.2f%%\n",yes,(float)yes/n*100);
    remain();
}

int total(void)
{
    FILE *fp;
    if((fp=fopen("test1.txt","r"))==NULL)
    {
        printf("打开文件失败!");
        exit(0);
    }
    int n=0;
    char c;
    c=fgetc(fp);
    do
    {        
        if(c=='\n')
            n++;
        c=fgetc(fp);
    }while(!feof(fp));
    return n;
}

void getInput(struct Test *test)
{
    int i,n;
    printf("你将输入多少道试题?\n");
    scanf("%d",&n);
    FILE *fp;
    if((fp=fopen("test1.txt","a"))==NULL)
    {
        printf("打开文件错误!\n");
        exit(0);
    }
    test=(struct Test *)malloc(LEN);
    for(i=1;i<=n;i++)
    {
        printf("题目:");
        scanf("%s",test->que);
        printf("A.");
        scanf("%s",test->answer1);
        printf("B.");
        scanf("%s",test->answer2);
        printf("C.");
        scanf("%s",test->answer3);
        printf("D.");
        scanf("%s",test->answer4);
        printf("正确答案:");
        scanf("%s",test->ture);

        fputs(test->que,fp);
        fputs(" A.",fp);
        fputs(test->answer1,fp);
        fputs(" B.",fp);
        fputs(test->answer2,fp);
        fputs(" C.",fp);
        fputs(test->answer3,fp);
        fputs(" D.",fp);
        fputs(test->answer4,fp);
        fputs(" 正确答案:",fp);
        fputs(test->ture,fp);
        fputc('\n',fp);
    }
    fclose(fp);
    free(test);
    remain();
}

void remain()
{
    int flag;
    printf("1.返回主菜单\n");
    printf("2.退出程序\n");
    printf("请输入你的选择:\n");
    scanf("%d",&flag);
    switch(flag)
    {
        case 1: main(); break;
        case 2: exit(0);break;
        default:printf("输入错误!");
    }
}

//void main()
int main(void)
{
    struct Test test;
    int flag;
    printf("--------单项选择题标准化考试系统--------\n");
    printf("1.录入试题\n");
    printf("2.自主测试\n");
    printf("3.退出程序\n");
    printf("请输入你的选择:\n");
    scanf("%d",&flag);
    switch(flag)
    {
        case 1: getInput(&test); break;
        case 2: testing(); break;
        case 3: exit(0); break;
        default:printf("输入错误!\n");
    }
    return 0;
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-6-23 00:09:20 | 显示全部楼层

太太太感谢了!!!!!!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-6-23 10:15:14 | 显示全部楼层

现在人还“健在”吧啊哈哈哈
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-6-23 14:22:34 | 显示全部楼层
Gacy 发表于 2021-6-23 10:15
现在人还“健在”吧啊哈哈哈

还健在啊哈哈
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-9-21 14:41

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表