//#include<bits/stdc++.h>//<<fixed<<setprecision(2)
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;//for(int i=1;i<=a;i++)
int main()
{
long double a,f,g,h,i=1,j,u=0;
char c,e;
long long b=1,d;
cout<<"这是计算机"<<endl<<"输入“5478278”,并快速按两次回车键即可退出此程序" <<endl<<"按“888”表示知道了"<<endl;
cin>>j;
if(j!=888)
{
while(j!=888)
{
if(j!=888)
{
cout<<"???"<<endl;
cin>>j;
}
if(j==888)
for(int i=1;i<=24;i++)
cout<<endl;
}
}
else
for(int i=1;i<=24;i++)
cout<<endl;
cout<<"请输入密码:";
cin>>a;
if(a==1478278)
{
cout<<"需保留几位小数?"<<endl;
cin>>h;
while(h>100)
{
if(u!=4)
{
cout<<"小数数位太多了!"<<endl<<"请再次输入:";
}
cin>>h;
u++;
if(u==4)
{
cout<<"最多100位!"<<endl;
u=0;
}
}
while(1)
{
cout<<"请输入算式:" ;
cin>>b;
if(b==5478278)
break;
cin>>c>>d>>e;
if(c=='+')
g=b+d;
if(c=='-')
g=b-d;
if(c=='*')
g=b*d;
if(c=='/')
g=float(b)/float(d);
if(c=='%')
g=b%d;
cout<<fixed<<setprecision(h)<<g<<endl;
}
}
else
{
while(a!=1478278)
{
cout<<"密码错误"<<endl<<"请再次输入密码:";
cin>>a;
if(a==5478278)
break;
}
cout<<"需保留几位小数?"<<endl;
cin>>h;
while(h>100)
{
if(u!=4)
{
cout<<"小数数位太多了!"<<endl<<"请再次输入:";
}
cin>>h;
u++;
if(u==4)
{
cout<<"最多100位!"<<endl;
u=0;
}
}
while(1)
{
cout<<"请输入算式:" ;
cin>>b;
if(b==5478278)
break;
cin>>c>>d>>e;
if(c=='+')
g=b+d;
if(c=='-')
g=b-d;
if(c=='*')
g=b*d;
if(c=='/')
g=float(b)/float(d);
if(c=='%')
g=b%d;
cout<<fixed<<setprecision(h)<<g<<endl;
}
}
return 0;
}
计算机
最新推荐文章于 2024-06-19 09:25:03 发布