OJ期末刷题 Problem I: C/C++经典程序训练3---模拟计算器

来源:互联网 发布:类似于云客宝的软件 编辑:程序博客网 时间:2024/04/28 14:06

Description

简单计算器模拟:输入两个整数和一个运算符,输出运算结果;

Input

第一行输入两个整数; 第二行输入一个运算符(+、-、*、/);

Output

输出对两个数运算后的结果;

Sample Input

30 50*

Sample Output

1500

代码:

#include <iostream>using namespace std;int main(){    int a,b;    double c;    char d;    cin>>a>>b;    cin>>d;    switch (d)    {    case '+':        c=a+b;        break;    case '-':        c=a-b;        break;    case '*':        c=a*b;        break;    case '/':        c=a/b;        break;    }    cout<<c;    return 0;}

运行结果:



学习心得:

好好学习 天天向上


0 0