C/C++经典程序训练3---模拟计算器
来源:互联网 发布:js取消onblur事件 编辑:程序博客网 时间:2024/04/28 14:55
C/C++经典程序训练3---模拟计算器
Time Limit: 1000MS Memory Limit: 8192KB
Problem Description
简单计算器模拟:输入两个整数和一个运算符,输出运算结果。
Input
第一行输入两个整数,用空格分开;
第二行输入一个运算符(+、-、*、/)。
所有运算均为整数运算,保证除数不包含0。
Output
输出对两个数运算后的结果。
Example Input
30 50*
Example Output
1500
代码如下:
import java.util.*;class counter{private int x;private int y;counter(int a, int b){x = a;y = b;}int add(){return (x + y);}int sub(){return (x - y);}int mul(){return (x * y);}int div(){return (x / y);}}public class Main{public static void main(String args[]){Scanner input = new Scanner(System.in);int A = input.nextInt();int B = input.nextInt();char C = input.next().charAt(0);counter cou = new counter(A, B);switch(C){case '+' : System.out.println(cou.add()); break;case '-' : System.out.println(cou.sub()); break;case '*' : System.out.println(cou.mul()); break;case '/' : System.out.println(cou.div()); break;}input.close();}}
0 0
- [1133]C/C++经典程序训练3—模拟计算器
- C/C++经典程序训练3---模拟计算器
- C/C++经典程序训练3---模拟计算器 (sdut oj)
- C/C++经典程序训练3---模拟计算器
- C/C++经典程序训练3---模拟计算器
- C/C++经典程序训练3---模拟计算器
- C/C++经典程序训练3---模拟计算器
- C/C++经典程序训练3---模拟计算器
- C/C++经典程序训练3---模拟计算器
- C/C++经典程序训练3---模拟计算器
- C/C++经典程序训练3---模拟计算器
- 第十五周 刷OJ题-C/C++经典程序训练3之模拟计算器
- OJ期末刷题 Problem I: C/C++经典程序训练3---模拟计算器
- sdut_java_C/C++经典程序训练3---模拟计算器
- C++经典训练3---模拟计算器
- Java sdut acm 1133 CC++经典程序训练3---模拟计算器
- 【C语言】 模拟计算器
- 1135C/C++经典程序训练5---图形打印问题
- 使用jdbc对MySQL数据库进行增删改查
- Android:简单动画效果-淡入淡出播放
- 19.ConcurrentHashMap
- centos7下的基于nginx的fastcgi环境搭建及样例测试
- platform驱动学习二之led测试实例
- C/C++经典程序训练3---模拟计算器
- 蓝桥杯 历届试题 打印十字图
- 计蒜客-火柴棍游戏
- 算法训练 字符删除
- 【NOI OJ】1816 拨钟问题
- 半数单集
- HDOJ 3788 ZOJ问题(观察推断题)
- 操作系统小练习5
- HDU 5353 模拟