1 条题解
-
0
C++ :
#include<bits/stdc++.h> using namespace std; int main(){ double a,b; char c; cin>>a>>b>>c; if(c=='*'){ printf("%.1lf",a*b); } else if(c=='/'){ printf("%.1lf",a/b); } else if(c=='+'){ printf("%.1lf",a+b); } else if(c=='-'){ printf("%.1lf",a-b); }else if(c!='-'&&c!='+'&&c!='*'&&c!='/')cout<<"运算符有误"; }
Python :
# coding=utf-8 x=float(input()) y=float(input()) op=input() if op=="+": z=x+y print(format(z,'.1f')) elif op=="-": z=x-y print(format(z,'.1f')) elif op=="*": z=x*y print(format(z,'.1f')) elif op=="/": z=x/y print(format(z,'.1f')) else: print("运算符有误")
- 1
信息
- ID
- 533
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- (无)
- 递交数
- 0
- 已通过
- 0
- 上传者