//请看功能介绍,附:C++98 CALC V2.1可以更改屏幕颜色
#include<windows.h>
#include<iostream>
#include<unistd.h>
#include<iomanip>
#include<cmath>
#include<ctime>
using namespace std;
void time() {
time_t now = time(0);
tm *localTime = localtime(&now);
cout << "·当前时间: ";
cout << (localTime->tm_year + 1900) << "-"
<< (localTime->tm_mon + 1) << "-"
<< localTime->tm_mday << " "
<< localTime->tm_hour << ":"
<< localTime->tm_min << ":"
<< localTime->tm_sec << endl;
cout << endl;
}
long double jia(long double a,long double b) {
cout << "输入第一个加数" << endl;
cin >> a;
cout << "输入第二个加数" << endl;
cin >> b;
cout << fixed << a + b << endl << endl;
time();
}
long double jian(long double a,long double b) {
cout << "输入被减数" << endl;
cin >> a;
cout << "输入减数(比被减数小)" << endl;
cin >> b;
cout << fixed << a - b << endl;
time();
}
long double cheng(long double a,long double b) {
cout << "输入第一个乘数" << endl;
cin >> a;
cout << "输入第二个乘数" << endl;
cin >> b;
cout << fixed << a * b << endl;
time();
}
int chu(int a,int b) {
cout << "输入被除数" << endl;
cin >> a;
cout << "输入除数(比除数小,不得为0)" << endl;
cin >> b;
if (a % b != 0) cout << a / b << "······" << a % b << endl;
else cout << cout << a / b << endl;
time();
}
int chf(int a,int b) {
cout << "[x]的[y]次方?(按顺序输入x与y)" << endl;
cin >> a >> b;
cout << pow(a,b) << endl;
time();
}
int main() {
int s;
mainc:
cout << " CCCCCCCCCCC 999999999 888888888" << endl;
cout << " CCCCCCCCCCCCC BL_TURTLE's CansLC 99999999999 88888888888" << endl;
cout << "CCCC 9999 9999 888 888" << endl;
cout << "CCC +++ +++ 999 999 888 888" << endl;
cout << "CCC +++ +++ 9999 9999 888 888" << endl;
cout << "CCC +++++++++++ +++++++++++ 99999999999 88888888888" << endl;
cout << "CCC +++++++++++ +++++++++++ 999999999 88888888888" << endl;
cout << "CCC +++ +++ 999 888 888" << endl;
cout << "CCC +++ +++ 999 888 888" << endl;
cout << "CCCC 999 888 888" << endl;
cout << " CCCCCCCCCCCCC C++98 CALC V2.1 999 88888888888" << endl;
cout << " CCCCCCCCCCC 999 888888888" << endl;
cout << "------------------------------------------------------------------------" << endl;
cout << "欢迎使用 C++98 计算器!" << endl << endl;
// cout << "版本: Calc V2.1" << endl;
// cout << "开发: BL_TURTLE's CansLC(2025/4/21,V2.1测试版)" << endl;
cout << "想做什么? 使用[1] 使用Windows计算器[2] 退出[3] 功能介绍[4] 设置[5]" << endl;//新增设置
cin >> s;
if (s == 1) {
usec:
cout << "加法[1]" << endl;
cout << "减法[2]" << endl;
cout << "乘法[3]" << endl;
cout << "除法[4]" << endl;
cout << "乘方[5]" << endl;
cout << "显示时间[6]" << endl;
cout << "回到主界面[7]" << endl;
int sss,a,b;cin >> sss;
if (sss == 1) {
jia(a,b);
cout << "回到哪里? 主界面[1] “使用”界面[2]" << endl;
int gotowhere;cin >> gotowhere;
if (gotowhere == 1) {
cout << endl;
goto mainc;
}
else if (gotowhere == 2) {
cout << endl;
goto usec;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
goto mainc;
}
}
else if (sss == 2) {
jian(a,b);
cout << "回到哪里? 主界面[1] “使用”界面[2]" << endl;
int gotowhere;cin >> gotowhere;
if (gotowhere == 1) {
cout << endl;
goto mainc;
}
else if (gotowhere == 2) {
cout << endl;
goto usec;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
goto mainc;
}
}
else if (sss == 3) {
cheng(a,b);
cout << "回到哪里? 主界面[1] “使用”界面[2]" << endl;
int gotowhere;cin >> gotowhere;
if (gotowhere == 1) {
cout << endl;
goto mainc;
}
else if (gotowhere == 2) {
cout << endl;
goto usec;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
goto mainc;
}
}
else if (sss == 4) {
chu(a,b);
cout << "回到哪里? 主界面[1] “使用”界面[2]" << endl;
int gotowhere;cin >> gotowhere;
if (gotowhere == 1) {
cout << endl;
goto mainc;
}
else if (gotowhere == 2) {
cout << endl;
goto usec;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
goto mainc;
}
}
else if (sss == 5) {
chf(a,b);
cout << "回到哪里? 主界面[1] “使用”界面[2]" << endl;
int gotowhere;cin >> gotowhere;
if (gotowhere == 1) {
cout << endl;
goto mainc;
}
else if (gotowhere == 2) {
cout << endl;
goto usec;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
cout << endl;
goto mainc;
}
}
else if (sss == 6) {
cout << "因为开发人员技术Too Low,所以只能显示15秒的时间" << endl;
Sleep(1000);
cout << endl;
int Time = 15;
while (Time--) {
time_t rawtime;
struct tm *timeinfo;
char buffer[80];
time(&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer,sizeof(buffer),"%H:%M:%S",timeinfo);
cout << "\r" << buffer << flush;
sleep(1);
}
cout << endl << endl;
cout << "回到哪里? 主界面[1] “使用”界面[2]" << endl;
int gotowhere;cin >> gotowhere;
if (gotowhere == 1) {
cout << endl;
goto mainc;
}
else if (gotowhere == 2) {
cout << endl;
goto usec;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
cout << endl;
goto mainc;
}
}
else if (sss == 7) {
cout << endl;
goto mainc;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
cout << endl;
goto mainc;
}
}
else if (s == 2) {
system("calc");
cout << "还要继续? 要[1] 不要[2]" << endl;
int ss;cin >> ss;
if (ss == 1) {
while (1) {
system("calc");
}
}
else if (ss == 2) {
system("Color 0A");
cout << endl;
goto mainc;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
goto mainc;
}
}
else if (s == 3) {
goto end;
}
else if (s == 4) {
cout << "功能介绍:" << endl;
cout << "·运算数字范围更大(运用 “long double”)" << endl;
cout << "·选择想做什么用数字输入,取消符号输入" << endl;
cout << "·如果不想使用这个计算器,用“使用Windows计算器”选项打开Windows计算器" << endl;
cout << "·如果输入数字错误,将回到主界面而不是退出程序" << endl;
cout << "·这个版本只能输入数字" << endl;//新增一条介绍
jieshao:
cout << endl << "想做什么? 退出[1] 回到主界面[2]" << endl;
int ss;cin >> ss;
if (ss == 1) {
goto end;
}
else if (ss == 2) {
goto mainc;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
goto mainc;
}
}
else if (s == 5) {
shezhi:
cout << "设置页面:" << endl;
cout << "[1]颜色设置" << endl;
cout << "[2]使用教程" << endl;
cout << "[3]关于" << endl;
cout << "[4]离开" << endl;
int ss;cin >> ss;
if (ss == 1) {
cout << "[1]系统(浅灰文字,黑色背景)" << endl;
cout << "[2]绿色(绿色文字,黑色背景)" << endl;
cout << "[3]蓝色(蓝色文字,黑色背景)" << endl;
cout << "[4]青色(青色文字,黑色背景)" << endl;
cout << "[5]退出至“设置”页面" << endl;
cout << "注意暂时不可避免的错误:颜色发生变化后,屏幕上的一些文字会变多!" << endl;
int ss;cin >> ss;
if (ss == 1) {
system("color 07");
goto shezhi;
}
else if (ss == 2) {
system("color 0A");
goto shezhi;
}
else if (ss == 3) {
system("color 09");
goto shezhi;
}
else if (ss == 4) {
system("color 0B");
goto shezhi;
}
else if (ss == 5) {
goto shezhi;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
cout << endl;
goto mainc;
}
}
else if (ss == 2) {//设置里面的使用教程
cout << "C++98 CALC V2.1 的使用教程" << endl;
cout << "·请在输入运算数据或选择数据时,仅输入数字,否则陷入死循环" << endl;
cout << "·如果希望查看现在的时间,可以前往“使用”屏幕" << endl;
cout << "·如果遇到了一些BUG或其他问题,请联系我们[现在输入3,查看“联系我们”],我们将会解决" << endl;
cout << "回到哪里? 设置页面[1] 主屏幕[2]" << endl;
int ss; cin >> ss;
if (ss == 1) {
cout << endl;
goto shezhi;
}
else if (ss == 2) {
cout << endl;
goto mainc;
}
else if (ss == 3) {
cout << endl;
goto guanyv;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
cout << endl;
goto mainc;
}
}
else if (ss == 3) {
guanyv:
cout << "关于C++98 CALC" << endl;
cout << "版本: Calc V2.1" << endl;
cout << "适用: Dev-C++5.11" << endl;
cout << "开发: BL_TURTLE's CansLC(2025/4/25,V2.1正式版)" << endl;
cout << "博客: https://blog.csdn.net/B142434?type=blog" << endl;
cout << "洛谷: https://www.luogu.com.cn/user/1427890" << endl;
cout << "B站UID: 3546609795205173" << endl;
cout << "开发者的OJ: https://hydro.ac/d/BobOJ/" << endl;
cout << "联系我们: 434443625@qq.com" << endl;
cout << "退出至设置[1]" << endl;
int ss; cin >> ss;
if (ss == 1) {
cout << endl;
goto shezhi;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
cout << endl;
goto mainc;
}
}
else if (ss == 4) {
cout << endl;
cout << endl;
goto mainc;
}
else {
cout << "输入错误(已经回到主页面)" << endl;
cout << endl;
goto mainc;
}
}
else {
cout << "输入错误(已经回到主页面)" << endl;
cout << endl;
goto mainc;
}
end:
return 0;
}