产生四则运算
#include<stdio.h> #include<iostream> #include<stdlib.h> #include<time.h> #include<algorithm> using namespace std; int main() { int k; long int a,b,t; cin>>k; srand(time(NULL)); for(int i=0;i<k;i++) { a=rand()%100; b=rand()%100; t=rand()%4; switch(t) { case 0: cout<<a<<"+"<<b<<"="<<endl; break; case 1: if(a<b) { int temp; temp=a; a=b; b=temp; } cout<<a<<"-"<<b<<"="<<endl; break; case 2: cout<<a<<"*"<<b<<"="<<endl; break; case 3: if(b!=0) { cout<<a<<"/"<<b<<"="<<endl; } } } }