闲来无事,用c++写了个加减法练习的小程序,代码如下:
#include<iostream>
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
using namespace std;
int score=0,counter=0,righter=0;
const int rangeRandom(int nummin,int nummax=32767)
{
srand((int)time(NULL));
if (nummin>nummax){
swap(nummin,nummax);
}
int another_num=nummax-nummin;
if (another_num<=0){
return 0;
}
else if (another_num<32767){
return nummin+(rand()%another_num);
}
else{
return nummin+int(((rand()%32767)/32767)*another_num);
}
}
const int plusused(int m,int n,int p,int q){
int righter=0;
cout<<"接下来我们开始做"<<n<<"以内的加法练习~(共"<<p<<"题)"<<endl;
Sleep(600);
for(counter=0;counter<p;counter++){
int a=rangeRandom(m,n),c,d;
Sleep(