计算器
2025-08-01 14:48:14
发布于:广东
这是一个计算器代码
可以在ACGO上用
也可以在Dev-c++用
用ACGO的把死循环删掉
#include<iostream>
#include<cmath>
using namespace std;
double s(double a,char ty,double b){
double c=a;
if(ty=='+'){
c=a+b;
return c;
}else if(ty=='-'){
c=a-b;
return c;
}else if(ty=='*'){
c=a*b;
return c;
}else if(ty=='/'){
c=a/b;
return c;
}else if(ty=='%'){
int e=a,w=b;
c=e%w;
return c;
}else if(ty=='^'){
for(int i=1;i<b;i++){
c*=a;
}
return c;
}else if(ty=='s'){
return sqrt(a);
}
}
int main(){
double a,b;
char ty;
for(int i=1;i<=2;i--){
cin>>a>>ty>>b;
cout<<s(a,ty,b)<<"\n\n";
}
return 0;
}
根号为“数字a s 数字b(没用)”
@AC君,s是sqrt函数,没有恶意。
别封号
全部评论 5
禁止主包自娱自乐
2025-08-02 来自 浙江
0可以试一下
2025-08-02 来自 广东
0啥都可以算
2025-08-02 来自 广东
0很好用
2025-08-02 来自 广东
0哇,好棒啊
2025-08-02 来自 广东
0


















有帮助,赞一个