生成加法题
来源:互联网 发布:数据挖掘以什么为基础 编辑:程序博客网 时间:2024/06/07 03:24
使用rand()生成三个伪随机数,输出成一道加法题,然后验证结果。
使用while(1)一直循环,直到if(…)break;
#include<iostream>#include<string>#include<ctime>#include<cstdlib>using namespace std;int main(void){while(1){ srand(time(0)); int number1=rand() %100; int number2=rand() %100; int number3=rand() %100; cout<<number3<<"+"<<number2<<"+"<<number1<<"= ?"<<endl; int sum=number3+number2+number1; cout<<"the anwser is :"; int anwser=0; cin>>anwser; bool isCorrect=(anwser==sum); if(isCorrect) { cout<<"Congradulation!You are correct"<<endl; } else { cout<<"Sorry,you are wrong!"<<endl; } cout<<"Do you want to do it again?[yes/no]:"<<endl; string reslut;//错误 string reslut=0 将NULL赋值给std::string变量 cin>>reslut; if(reslut=="no") break; }return 0;}
0 0
- 生成加法题
- 随机数生成---加法学习工具
- 一道加法题
- 加法
- 加法
- 使用kaptcha插件生成加法计算验证码
- HDU - 1222 Wolf and Rabbit(加法生成元)
- 小学生趣味加法题 程序
- 【笔试题】整型提升加法
- 案例-加法随机算术题
- 华为上机题:高精度整数加法
- Hulu笔试编程题--大整数加法
- BOP -- 只考加法的题
- (c语法百题2)加法
- 【SzNOI语法百题】【d002】加法
- HDU1230 火星A+B 加法模拟题
- PAT-有理数加法(基础编程题)
- 中级题:二师弟的星际加法
- Spring@Autowired注解与自动装配
- Oracle中的Hash Join祥解
- Oracle中的initrans-maxtrans
- 70.交换变量值
- VMware下ubuntu系统一直莫名其妙地连接无线网络导致Hadoop集群无法正常启动的解决方法
- 生成加法题
- Log4j自定义Appender介绍
- error C2872: “IDocument”: 不明确的符号
- sql笔记整理之索引和视图
- 通过例子学习Rust 前言
- 【app运营】3阶段解析O2O产品的APP该如何运营推广?
- Java EE Eclipse安装Tomcat插件 “工具栏不显示三只小猫”
- Android SDK r20 下载与安装教程
- UEFI+GPT安装ubuntu14.04笔记