zoukankan      html  css  js  c++  java
  • 一记日文题

    /*

    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;
        }
    }

     

  • 相关阅读:
    51nod贪心算法入门-----完美字符串
    HDU6030----矩阵快速幂
    O(n)求1~n的逆元
    (四)添加签到奖励功能
    (三)开始在OJ上添加签到功能
    (二)OJ的主要文件
    (一)在linux上ubuntu搭建hustOJ系统
    CF 148A Insomnia cure
    lower_bound和upper_bound
    C++ string的常用功能
  • 原文地址:https://www.cnblogs.com/jxust-jiege666/p/6438747.html
Copyright © 2011-2022 走看看