0
已解决
徐烨奎
新手光能
新手光能
#include<bits/stdc++.h>
using namespace std;
int main()
{
system("color F5");
cout<<"小小计算器\n";
cout<<"版本2.11,作者:徐烨奎\n";
cout<<"温馨提示:如果三次输入错误,则计算结束!\n";
cout<<"数不能超过100亿!\n" ;
char c;
double a,b;
cout<<"请输入一个符号(+加号,-减号,*乘号,/除号)\n";
cin>>c;
cout<<"请输入两个数\n";
cin>>a>>b;
if(a>=10000000000||b>=10000000000){
system("cls");
cout<<"数字超标";
return 0;
}
if(c=='+'||c=='-'||c=='*'||c=='/'){
system("cls");
cout<<"计算结束"<<endl<<"结果是:";
if(c=='+'){
cout<<a+b;
}
else if(c=='-'){
cout<<a-b;
}
else if(c=='*'){
cout<<a*b;
}
else if(c=='/'){
cout<<a/b;
}
}
if(c!='+'&&c!='-'&&c!='*'&&c!='/'){
system("cls");
cout<<"输入错误\n请重新输入\n";
char c;
double a,b;
cout<<"请输入一个符号(+加号,-减号,*乘号,/除号)\n";
cin>>c;
cout<<"请输入两个数\n";
cin>>a>>b;
}
else if(c!='+'&&c!='-'&&c!='*'&&c!='/'){
system("cls");
cout<<"输入错误\n请重新输入\n";
char c;
double a,b;
cout<<"请输入一个符号(+加号,-减号,*乘号,/除号)\n";
cin>>c;
cout<<"请输入两个数\n";
cin>>a>>b;
system("cls");
}
if(c=='+'||c=='-'||c=='*'||c=='/'){
cout<<"计算结束"<<endl<<"结果是:";
if(c=='+'){
cout<<a+b;
}
else if(c=='-'){
cout<<a-b;
}
else if(c=='*'){
cout<<a*b;
}
else if(c=='/'){
cout<<a/b;
}
}
else if(c!='+'&&c!='-'&&c!='*'&&c!='/'){
cout<<"输入错误";
return 0;
}
system("color 5F");
return 0;
}
0
0
包涵宇
中级天翼
中级天翼
我编的计算器:
#include<iostream>
#include<windows.h>
#include<bits/stdc++.h>
using namespace std;
string cut;
void out(string s){
for(int i=0;i<s.size();i++){
cout<<s[i];
Sleep(40);
}
cout<<"\n";
}
long double mmmm,mmm;
char ddd;
cut="请输入(请不要再两边输字符,不然程序会卡的!!!):";
out(cut);
cin>>mmm>>ddd>>mmmm;
if(ddd=='+')cout<<mmm+mmmm;
else if(ddd=='-')cout<<mmm-mmmm;
else if(ddd=='*')cout<<mmm*mmmm;
else if(ddd=='/')cout<<mmm/mmmm;
else cout<<"输入错误!!!\a";
Sleep(1500);
}
}