no1caiji 2020-01-11 15:15
浏览 265

(自己搞定了)C++编写一个在单词本内单词测试的程序,求大佬捉虫

1.错误代码LINK2019,LINK1120

#include "exam.h"
#include "ui.h"
#include <iostream>
#include <string>
#include "stdlib.h"
#include "time.h"

using namespace std;

static const string exam_ui_prompt =
"\n\n"
"\t|*******************************|\n"
"\t|*   请您选择考试类别        *|\n"
"\t|*       1 看中文写英文        *|\n"
"\t|*       2 看英文写中文        *|\n"
"\t|*       3 看解释写成语        *|\n"
"\t|*       0 返回上级          *|\n"
"\t      请输入(1,2,3或0):  ";

void exam_ui() {
    void exam_ui_english_for_chinese(); {
        //装载词库
        dict_load(
            &dictionaries[ENGLISH_CHINESE],
            DICT_PATH DICT_ENGLISH_CHINESE
        );

        //生成考试题目
        Examination exam;
        exam_create(&exam, &dictionaries[ENGLISH_CHINESE]);
        for (int i = 0; i < exam.words.size(); i++) {
            CLEAR();
            cout << "\n\n";
            cout << "\t|**************************|\n";
            meaning_display(exam.meanings[i]);
            cout << "\n";
            cout << "\t|*************************|\n";
            string word = get_input_string("\t   请输入英文答案(0 退出) : ");
            cout << "\t 请输入英文答案 (0 退出):";
            std::getline(cin, word);
            if (word == exam.words[i]) {
                cout << "\t  正确!!!" << endl;
                string op = get_input_string("\t  请输入(0 退出, 其他  下一题):");
                if (bool op = "0") {
                    break;
                }
            }
            else if (word == "0") {
                break;
            }
            else {
                cout << "\t    错误, 继续加油哦" << endl;
                    //继续下去还答这道题
                    i--;
            }
        }
    }
    CLEAR();
    cout << exam_ui_prompt;
    string op;
    std::getline(cin, op);
    if (op == "1") {
        exam_ui_english_for_chinese();
    }
    else if (op == "2") {

    }
    else if (op == "0") {
        return;
    }
    exam_ui();
}
/**
生成一个[min,max)之间的随机整数
*/
 static int radom_index(int min, int max) {
    return (int)(min + (double)rand() / (double)RAND_MAX * (max - min));
}
/*
从字典随机生成一个试卷
*/
void exam_create(Examination* exam, Dictionary* dict) {
    srand(time(NULL));
    int wordcount = dict->words.size();
    int itemcount = wordcount < 10 ? wordcount : 10;
    for (int i = 0; i < itemcount; i++) {
        int idx = radom_index(0, wordcount);
        exam->words.push_back(dict->words[idx]);
        exam->meanings.push_back(dict->meanings[idx]);
    }
}

void exam_ui_display()
{
    return;
}

void exam_ui_chinese_for_english()
{
    return;
}

void exam_ui_english_for_chinese()
{
}


3.我看我的头文件里都声明定义了但我还是不知道怎么解决这个错误

#ifndef _EXAM_H
#define _EXAM_H

#include <string>
#include <vector>
#include "dict.h"

using namespace std;

typedef struct {
    vector<string>words;
        vector< vector < string > >meanings;
}Examination;

void exam_create(Examination* exam, Dictionary* dict);

void exam_ui_display();
void exam_ui_chinese_for_english();
void exam_ui_english_for_chinese();

bool op;
string word;

#endif//!_EXAM_H



  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
    • ¥15 使用phpstudy在云服务器上搭建个人网站
    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
    • ¥15 画两个图 python或R
    • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
    • ¥15 八路抢答器设计出现故障
    • ¥15 opencv 无法读取视频