这个系列会有很多篇文章,每篇都是计算天天练/质数合数天天练
完整代码:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <climits>
#include <ctime>
#include <cstdlib>
#include <windows.h>
using namespace std;
//判断是否互质
int judge_relatively_prime(int a,int b){
for (int i = 2;i < min(a,b);i++){
if (a % i == 0&&b % i == 0){//判断是否互质
return 0;//不互质返回0
}
}
return 1;//否则返回1
}
int main(){
srand(time(0));
printf("程序开始!\n");
printf("先看看好玩的吗?\n");
printf("打一个数字1\n");
int a,cnt = 0;
cin >> a;
if (a == 1){
printf(" 你知道吗,贝类有一个特殊的习惯!");
printf("别的动物啊都把自己的粪便和尿液排在体外,但是据研究发现,几乎所有贝壳都把自己的排泄物排在体内!!!");
} else {
cout << "本来你还可以做做题的,但因为你不听话,取消资格" << endl;
cout << "程序结束" << endl;
return 0;
}
printf("可能数字有点大,但是可以笔算\n");
int haha = 0;
int b[100],c[100],d[100],e[100];
for (int i = 0;i < 10;i++){
b[i] = rand();
}
for (int i = 0;i < 50;i++){
e[i] = rand();
}
for (int i = 35;i < 45;i++){
c[haha] = e[i];
haha++;
}
for (int i = 0;i < 10;i++){
if (i % 2 == 0){
printf("%d + %d = ?,请输入答案:",b[i],c[i]);
cin >> d[i];
if (d[i] == b[i] + c[i]){
printf("正确,得1分");
cnt++;
} else {
printf("错误");
}
cout << endl;
} else {
printf("%d - %d = ?,请输入答案:",b[i],c[i]);
cin >> d[i];
if (d[i] == b[i] - c[i]){
cnt++;
printf("正确,得1分");
} else {
printf("错误");
}
cout << endl;
}
}
if (cnt == 10){
printf("你得了满分!\n");
printf("你真棒,再接再厉!\n");
printf("以后考试还会更新\n");
printf("程序结束\n");
} else {
printf("你得了%d分\n",cnt);
printf("加油,争取下一次满分!\n");
printf("以后考试还会更新哦\n");
}
printf("计算天天练1.1、1.2、1.3、2.0版本即将出版,敬请期待\n");
return 0;
}
最后大家投个票,愿意继续更新的在第一个里面投A,中立投B,不愿意投C,再写个理由