对于c++来说,最简单的就是四则运算了,这里有一个四则运算的计算器

#include <stdio.h> 
#include<conio.h>
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
for(;;){
cout<<"欢迎来到加减乘除四则运算,";
cout<<"请按任意键继续";
getch(); 
system("cls");
for(int i=0;i<=12;i++){
cout<<"-";
}
cout<<endl;
cout<<"| 1.加法运算|\n";
cout<<"| 2.减法运算|\n";
cout<<"| 3.乘法运算|\n";
cout<<"| 4.除法运算|\n";
cout<<"| 5.退出运算|\n";
for(int i=0;i<=12;i++)
{
cout<<"-";
}
cout<<endl;
int a;
cin>>a;
system("cls");
int o,t;
if(a==1){
cout<<"请输入两个数:";
cin>>o>>t;
system("cls");
cout<<o<<"+"<<t<<"="<<o+t;
cout<<endl;
}else if(a==2){
cout<<"请输入两个数:";
cin>>o>>t;
system("cls");
cout<<o<<"-"<<t<<"="<<o-t;
cout<<endl;
}else if(a==3){
cout<<"请输入两个数:";
cin>>o>>t;
system("cls");
cout<<o<<"*"<<t<<"="<<o*t;
cout<<endl;
}else if(a==4){
cout<<"请输入两个数:";
cin>>o>>t;
system("cls");
cout<<o<<"/"<<t<<"="<<o/t;
cout<<endl;
}else{
cout<<"十分的感谢您,再见!";
break;
}
}
return 0;
}
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值