四则运算 来自 http://www.cnblogs.com/ys1101/p/4368103.html
#include<stdio.h>
#include<math.h>
#include<windows.h>
int right=;
int wrong=;
void add()
{
int a,b,c,d;
a=rand()%;
b=rand()%;
printf("请回答:\n\t\t %d + %d = ",a,b);
scanf("%d",&c);
if(a+b==c)
{
printf("回答正确!\n");
right++;
}
else
{
printf("回答错误!\n");
wrong++;
}
}
void minu()
{
int a,b,c;
a=rand()%;
b=rand()%;
printf("请回答:\n\t\t %d - %d = ",a,b);
scanf("%d",&c);
if(a-b==c)
{
printf("回答正确!\n");
right++;
}
else
{
printf("回答错误!\n");
wrong++;
}
}
void mul()
{
int a,b,c;
a=rand()%;
b=rand()%;
printf("请回答:\n\t\t %d * %d = ",a,b);
scanf("%d",&c);
if(a*b==c)
{
printf("回答正确!\n");
right++;
}
else
{
printf("回答错误!\n");
wrong++;
}
}
void di()
{
int a,b,c;
a=rand()%;
b=rand()%;
printf("请回答:\n\t\t %d / %d = ",a,b);
scanf("%d",&c);
if(a/b==c)
{
printf("回答正确!\n");
right++;
}
else
{
printf("回答错误!\n");
wrong++;
}
}
void main()
{
int choise;
int con=;
printf("\n\t\t\t欢迎进入小学简易四则运算\n\n");
while()
{
printf("请选择:\n");
printf("\t\t\t 加法运算(请输入1)\n");
printf("\t\t\t 减法运算(请输入2)\n");
printf("\t\t\t 乘法运算(请输入3)\n");
printf("\t\t\t 除法运算(请输入4)\n");
printf("\t\t\t 退出运算(请输入5)\n");
if(con==)
scanf("%d",&choise);
switch(choise)
{
case :
add();
break;
case :
minu();
break;
case :
mul();
break;
case :
di();
break;
case :
return;
}
printf("\n\t\t\t继续运算?(请输入1)\n");
printf("\n\t\t\t重新选择?(请输入2)\n");
printf("\n\t\t\t退出运算?(请输入3)\n");
scanf("%d",&con);
if(con==)
con=;
else if(con==)
con=;
else if(con==)
break;
else
printf("抱歉!,你输入的指令有误!请重新输入!\n");
}
printf("您总共完成了 %d 道题\n正确 %d 道\n错误 %d 道\n",right+wrong,right,wrong);
}
四则运算 来自 http://www.cnblogs.com/ys1101/p/4368103.html的更多相关文章
- liunx-centos-基础命令详解(1) -主要内容来自 —https://www.cnblogs.com/caozy/p/9261224.html
关机:halt/poweroff :立刻关机reboot :立刻重启 shutdown -r now :立刻重启shutdown -h 00:00 :定时重启 now:立刻shutdown -h +n ...
- 随笔二-https://www.cnblogs.com/shang1680/p/9657994.html
作业要求来自https://edu.cnblogs.com/campus/gzcc/GZCC-16SE2/homework/2097 GitHub远程仓库的地址:https://github.com/ ...
- 源自http://www.cnblogs.com/sciencefans/p/4394861.html
人脸识别的四大块:Face detection, alignment, verification and identification(recognization),本别代表从一张图中识别出人脸位置, ...
- 按需加载.js .css文件
首先,理解按需加载当你需要用到某个js里面的函数什么鬼,或者某个css里的样式的时候你才开始加载这个文件. 然后是怎样实现的,简单来说就是在js中动态的createElem<script> ...
- github入门到上传本地项目【网上资源整合】
[在原文章的基础上,修改了描述的不够详细的地方,对内容进行了扩充,整合了网上的一些资料] [内容主要来自http://www.cnblogs.com/specter45/p/github.html#g ...
- 支付宝web支付
过程 1. 用户下单 2. 商户后台产生订单 3. 请求支付宝web支付页面(将订单信息返回给用户---放在form里面---隐藏起来-----并通过脚本自动提交此form到支付宝web支付页) 4. ...
- ★Kali信息收集~ 1.Google Hacking + Github Hacking
一.google hacking site site:cnblogs.com 毒逆天 intitle intitle:login allintitle allintitle:index of alli ...
- WebComponent魔法堂:深究Custom Element 之 面向痛点编程
前言 最近加入到新项目组负责前端技术预研和选型,一直偏向于以Polymer为代表的WebComponent技术线,于是查阅各类资料想说服老大向这方面靠,最后得到的结果是:"资料99%是英语 ...
- Storm中遇到的日志多次重写问题(一)
业务描述: 统计从kafka spout中读取的数据条数,以及写入redis的数据的条数,写入hdfs的数据条数,写入kafaka的数据条数.并且每过5秒将数据按照json文件的形式写入日志.其中保存 ...
随机推荐
- Buildroot用户指南【转】
本文转载自:http://www.voidcn.com/blog/bytxl/article/p-4727302.html 第一章 关于Buildroot Buildroot是一个包含M ...
- C++ pair(对组)用法(转)
类模板:template <class T1, class T2> struct pair 参数:T1是第一个值的数据类型,T2是第二个值的数据类型. 功能:pair将一对值组合成一个值, ...
- python库学习笔记——BeautifulSoup处理子标签、后代标签、兄弟标签和父标签
首先,我们来看一个简单的网页https://www.pythonscraping.com/pages/page3.html,打开后: 右键"检查"(谷歌浏览器)查看元素: 用导航树 ...
- bzoj 4753 最佳团体 —— 01分数规划+树形背包
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4753 注意赋初值为 -inf: eps 设为 1e-3 会 WA ... 代码如下: #in ...
- sql 指删除表,改表名,改字段名
删除表: DECLARE @Table NVARCHAR(30) DECLARE tmpCur CURSOR FOR SELECT name FROM sys.objects WHERE TYPE=' ...
- Navicat: Can't create a procedure from within another stored routine
测试调用mysql的存储过程,于是用Navicat写,结果报这个错误,源代码如下: CREATE PROCEDUREQueryDate() BEGIN SELECTCURDATE(); E ...
- Html.PartialView(),html.Renderpartial,html.action.html.RenderAction 辅助方法
Html.Partial(), 返回HTML字符串 .参数为部分视图 html.RenderPartial(),不返回返回HTML字符串 ,直接输出响应流.参数为部分视图 一般用于主视图中已经存在了这 ...
- P2479 [SDOI2010]捉迷藏
传送门 KDtree是个吼东西啊-- 枚举每一个点,然后求出离他距离最远和最近的点的距离,更新答案 然而为什么感觉KDtree只是因为剪枝才能跑得动呢-- //minamoto #include< ...
- linux ls touch、umask、 chattr
1.$PATH2.ls -al ~ (~ 显示隐藏的文件) 3$ cd ~ // 回到自己的主文件4.cp /var/log/wtmp . //复制到当前目录,最后的“.”不要忘 ls -l /var ...
- _bzoj1012 [JSOI2008]最大数maxnumber【Fenwick Tree】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1012 裸的树状数组. #include <cstdio> #include &l ...