不要让昨天 占据你的今天 夏午晴天

夏午晴天

一记日文题

/*

2つの整数 a, b と1つの演算子 op を読み込んで、a op b を計算するプログラムを作成して下さい。ただし、演算子 op は、"+"(和)、"-"(差)、"*"(積)、"/"(商)、のみとし、割り算で割り切れない場合は、小数点以下を切り捨てたものを計算結果とします。

Input

入力は複数のデータセットから構成されています。各データセットの形式は以下のとおりです:

a op b

op が '?' のとき 入力の終わりを示します。このケースの出力は行ってはいけません。

Output

各データセットについて、計算結果を1行に出力して下さい。

Constraints

  • 0 ≤ a, b ≤ 20000
  • 0 による割り算が与えられることはありません。

Sample Input

1 + 2
56 - 18
13 * 2
100 / 10
27 + 81
0 ? 0

Sample Output

3
38
26
10
108

*/

 

#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int main() {
    long long a,b;
    char s;
    while(cin>>a>>s>>b)
    {
        if(s == '?')
            break;
        if(s == '+')
            cout<<a+b<<endl;
        else if(s == '-')
            cout<<a-b<<endl;
        else if(s == '*')
            cout<<a*b<<endl;
        else if(s == '/')
            cout<<a/b<<endl;
    }
}

 

 

posted on 2017-02-24 15:26  夏晴天  阅读(127)  评论(0编辑  收藏  举报

导航

Live2D