四则运算出题

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
char fun(int x){
  if(x==0)
   return '+';
   if(x==1)
    return '-';
   if(x==2)
    return '*';
   if(x==3)
    return '/';
}
int fuu(int a,int b,char c){
  if(c=='+')
  return a+b;
  if(c=='-')
   return a-b;
  if(c=='*')
    return a*b;
  if(c=='/')
    return a/b;
}
int main(){
  int a,b;
  char c;
  for(int i=0;i<300;i++){
    cout<<"Problem is:"<<endl;
    a=rand();
    b=rand();
    c=fun(rand()%4);
    cout<<a<<" "<<c<<" "<<b<<" = "<<endl;
    cout<<"Answer is: ";
    cout<<fuu(a,b,c)<<endl;
    cout<<rand()<<endl;

  }

}



原文地址:https://www.cnblogs.com/CJFQT/p/8526341.html