http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782
题意:把输入的三元运算用计算机运算出来。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main() {
 4     int t;
 5     cin>>t;
 6     while(t--) {
 7         int a,b,c;
 8         int s1=;
 9         char n,m;
         cin>>a>>n>>b>>m>>c;
         if(n=='*'||n=='/'||n=='%') {
             if(n=='*')
                 s1=a*b;
             else if(n=='/')
                 s1=a/b;
             else
                 s1=a%b;
             if(m=='*')
                 s1=s1*c;
             else if(m=='/')
                 s1=s1/c;
             else if(m=='%')
                 s1=(int)s1%c;
             else if(m=='+')
                 s1=s1+c;
             else if(m=='-')
                 s1=s1-c;
         } else if(m=='*'||m=='/'||m=='%') {
             if(m=='*')
                 s1=b*c;
             else if(m=='/')
                 s1=b/c;
             else if(m=='%')
                 s1=b%c;
             if(n=='+')
                 s1=a+s1;
             else if(n=='-')
                 s1=a-s1;
 
         } else {
             if(n=='+')
                 s1=a+b;
             else if(n=='-')
                 s1=a-b;
             if(m=='+')
                 s1=s1+c;
             else if(m=='-')
                 s1=s1-c;
         }
         printf("%d\n",s1);
 
     }
     return ;
 }

The 11th Zhejiang Provincial Collegiate Programming Contest->Problem G:G - Ternary Calculation的更多相关文章

  1. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...

  2. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  3. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...

  4. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

  5. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502  The 12th Zhejiang Provincial ...

  6. zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...

  7. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504  The 12th Zhejiang Provincial ...

  8. zjuoj The 12th Zhejiang Provincial Collegiate Programming Contest Ace of Aces

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5493 The 12th Zhejiang Provincial ...

  9. 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)

    Floor Function Time Limit: 10 Seconds      Memory Limit: 65536 KB a, b, c and d are all positive int ...

  10. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - L Doki Doki Literature Club

    Doki Doki Literature Club Time Limit: 1 Second      Memory Limit: 65536 KB Doki Doki Literature Club ...

随机推荐

  1. FindControl 无法找到控件问题解决方案

    若用 string cdept =((HtmlInputText)FindControl("dept0" + i.ToString())).Value; 提示结果为空值,即无法找到 ...

  2. Ubuntu系统中Sogou输入法面板问题解决方案

    好消息- Ubuntu Kylin团队与搜狗公司合作开发了“搜狗输入法 for Linux”版本,支持Ubuntu 12.04 和 Ubuntu 14.04操作系统,在Sougou官网就可以下载到,附 ...

  3. response小结(四)

    1.发送http头,控制浏览器定时刷新网页(REFRESH). package com.yyz.response; import java.io.IOException; import javax.s ...

  4. HTML+CSS学习笔记(1) - Html介绍

    HTML+CSS学习笔记(1) - Html介绍 1.代码初体验,制作我的第一个网页 <!DOCTYPE HTML> <html> <head> <meta ...

  5. C# @符号的多种使用方法

    1.限定字符串用 @ 符号加在字符串前面表示其中的转义字符“不”被处理.如果我们写一个文件的路径,例如"D:/文本文件"路径下的text.txt文件,不加@符号的话写法如下:str ...

  6. (poj 3177) Redundant Paths

    题目链接 :http://poj.org/problem?id=3177 Description In order to <= F <= ,) grazing fields (which ...

  7. a2x

    #include <typeinfo> template <typename T> bool a2x( T& _f , char* p) { if( !p ) retu ...

  8. 普通树(有根树)C++

    对于普通树实现的细节包括 1 树结点的结构体 2 初始化及删除树结点(关注内存泄露) 3 递归先序遍历 4 通过关键值的查询操作,返回关键值的结点 5 凹入表实现 6 广义表实现 7 非递归先序遍历, ...

  9. 创建型模式——Builder

    1.意图 将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示. 2.结构 3.参与者 Builder为创建一个Product对象的各个部件指定抽象接口 ConcreteBuild ...

  10. Excel数据复制到Winform控件ListView

    先给窗体添加一个右键菜单contextMenuStrip 加一个下拉项[粘贴] 粘贴事件: private void tsmiPaste_Click(object sender, EventArgs ...