栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

C++基础与深度解析–project1 加减法练习

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

C++基础与深度解析–project1 加减法练习

1、project要求

2、project运行结果

3、peoject 代码

#include 
#include
#include"string.h"
#include 
using namespace std;
using namespace chrono;

int input_int()//输入判定,确保输入的是整数
{
    std::string in;
    std::cin>>in;
    while(in.find_first_of("0123456789")==std::string::npos||in.find_first_not_of("0123456789")!=std::string::npos){
        std::cout<<"error input,please input an integer!"<>in;
    }
    return std::stoi(in);
}

int main() {
    int fault=0;    //计算答错题目数量的变量
    char z[20];    //判定难易的字符
    int op;
    int right; //存储正确答案的值
    int int1;  //变量1
    int int2;  //变量2
    int opt; //+ - * /操作符分别对应不同的op值
    std::string opt_choice[4]{"+","-","*","/"};
    std::cout <<"欢迎来到答题系统!您可以选择题目的数量和难易程度;难易程度分为简单和难;简单题主要设计百以为的加减法;难题则除了含加减法,还包含乘除法"<< std::endl;
    std::cout <<"你选择的题目数量为:"<< std::endl;
    int num=input_int();
    int* storgeresult  = NULL;
    storgeresult  = new int[num];//存储答错题目正确答案

    int* index = NULL;
    index = new int[num];   //存储答错题号

    double* t = NULL;
    t = new double[num+2];//存储答题时间 后两位分别存储平均用时和最少用时
    std::cout <<"你选择的难易程度为:(请输入 simple or hard)"<< std::endl;

    std::cin >> z;
    while((strcmp(z,"simple")!=0)&&strcmp(z,"hard")!=0) {
        std::cout << "请输入 simple or hard" << std::endl;
        std::cin >> z;
    }
    if(strcmp(z,"simple")==0)
        op=2;  //如果简单,则只有加减法
    if(strcmp(z,"hard")==0)
        op=4;  //如果难,增加乘除法

    std::srand(time(nullptr));
    t[num]=0;

    for(int i=0;i0&&t[i]
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/589174.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号