c++口算题本

📅 2026/7/14 15:14:47 👁️ 阅读次数 📝 编程学习
c++口算题本

有没有家长想要孩子做口算题的?

话不多说上代码!!!

点个赞再复制吧

求求了!

这里要改一下!!!

#include<iostream> #include<time.h> #include<stdlib.h> #include<stdio.h> #include<cmath> using namespace std; int main(){ cout<<"欢迎来到口算制造机\nHow many 口算题 do uou need\n"; int youneed; cin>>youneed; cout<<"ok,你需要"<<youneed<<"份口算\n"; cout<<"你最多要整数部分是多少:"; int zure; cin>>zure; cout<<"\n你最多要小数部分是多少位:(不能是0)"; int number; cin>>number; cout<<"\n开始制造"; system("cls"); srand(time(0)); for(int j=1;j<=youneed;j++){ cout<<"-----------------------\n"; cout<<"这是第"<<j<<"份口算\n"; for(int i=1;i<=40;i++){ //cout<<"这是第"<<j<<"份口算\n"; int yu=pow(10,number); int op=rand()%4; int op11=rand()%zure; int op12=rand()%yu; int op21=rand()%zure; int op22=rand()%yu; string summ=to_string(op11)+"."+to_string(op12); double sum1=stod(summ); summ=to_string(op21)+"."+to_string(op22); double sum2=stod(summ); sum1++,sum2++; if(i%2==0) cout<<" "; if(op==1&&sum1>=sum2){ swap(op11,op21); swap(op12,op22); } if(op==0){ cout<<sum1<<"+"<<sum2<<"="; }else if(op==2){ cout<<sum1<<"*"<<sum2<<"="; }else if(op==1){ cout<<sum1<<"-"<<sum2<<"="; }else{ // 除法 int zeishu=rand()%yu; while(1){ if(zeishu!=0) break; zeishu=rand()%yu; } double sum3=sum1*zeishu; cout<<sum1<<"/"<<sum3<<"="; } if(i%2==0) cout<<"\n"; } } return 0; }