简易计算器
简易计算器设计。
输入格式:
输入两个非零整数,并在4 行中按顺序输出两个数的加、减、乘、除的计算结果。
输出格式:
要求输出格式如下,符号前后各有一个空格,具体参考输出样例:
整数1 + 整数2 = 和
整数1 - 整数2 = 差
整数1 * 整数2 = 积
整数1 / 整数2 = 商
输入样例:
在这里给出一组输入。例如:
1
2
输出样例:
在这里给出相应的输出。例如:
1 + 2 = 3
1 - 2 = -1
1 * 2 = 2
1 / 2 = 0.5
代码长度限制 16 KB
Python (python2)
时间限制 400 ms
内存限制 64 MB
Python (python3)
时间限制 400 ms
内存限制 64 MB
其他编译器
时间限制 400 ms
内存限制 64 MB
参考运行代码如下:
参考一:
one = int(input())
two = int(input())
print(one,"+",two,"=",one + two)
print(one,"-",two,"=",one - two)
print(one,"*",two,"=",one * two)
print(one,"/",two,"=",one / two)
参考二:
import math
a = int(input())
b = int(input())
add = a+b
sub = a-b
mul = a*b
div = a/b
print("{0:} + {1:} = {2:}".format(a,b,add))
print("{0:} - {1:} = {2:}".format(a,b,sub))
print("{0:} * {1:} = {2:}".format(a,b,mul))
print("{0:} / {1:} = {2:}".format(a,b,div))