1
已解决
李承耀
新手光能
新手光能
代码破1000行!
#include<bits/stdc++.h>
#include<windows.h>
#define clear_cin() fflush(stdin)
#define KAIJI 1
#define INA 2
using namespace std;
int kjhm,usernum;
bool vm;
char *p;
string kjdll="kj",lastkj="kj";
char user[10005][2][105]={{"",""},{"admin",""}};
int desktop(int);
void clear();
string getver(bool =true);
void shutdown(int =1);
void startup(int =0);
void s_d(int);
void error(string ="输入错误\n按Enter继续");
void notebook();
void setname();
void csh();
void ramtst(bool =false);
char _p(int);
int q(char);
int f(string,int);
string g(int,int);
void jzzh();
void gtuser();
void login();
void gjff();
void read_YOS();
void last_normal_shutdown();
int main(){
ramtst();
setname();
read_YOS();
csh();
startup();
clear();
while(1){
clear();
int type=desktop(INA);
if(type==0){
shutdown();
clear();
if(!vm)gjff();
if(!vm)
cout<<"现在可以安全的关闭此窗口了。";
return 0;
}
else if(type==1){
clear();
startup(2);
clear();
startup();
type=desktop(KAIJI);
}
clear();
}
if(!vm)
cout<<"现在可以安全的关闭此窗口了。";
return 0;
}
int desktop(int cs){
gtuser();
login();
clear();
cout<<"1.应用\n2.电源\n3.设置\n";
string s;
getline(cin,s);
clear();
if(s=="1"||s=="应用"||s=="1.应用"){
cout<<"1.版本号\n2.小小记事本\n3.数学工具\n4.虚拟机\n5.检测环境\n";
string s;
getline(cin,s);
clear();
if(s=="1"||s=="版本号"||s=="1.版本号"){
getver();
clear();
}
else if(s=="2"||s=="小小记事本"||s=="2.小小记事本"){
notebook();
setname();
}
else if(s=="3"||s=="数学工具"||s=="3.数学工具"){
cout<<"1.开根号\n2.加法\n3.减法\n4.乘法\n5.除法\n6.按位与\n7.按位或\n8.按位异或\n9.按位取反\n10.逻辑与\n11.逻辑或\n12.逻辑非\n13.逻辑相等\n14.进制转换\n";
getline(cin,s);
clear();
if(s=="1"||s=="sqrt"||s=="1.开根号"||s=="1.sqrt"||s=="开根号"){
cout<<"请输入您要开根号的值";
double n;
cin>>n;
clear();
if(n>=0)
cout<<n<<"开根号之后是"<<sqrt(n)<<endl;
else cout<<"负数没有平方根\n";
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="2"||s=="加法"||s=="2.加法"){
cout<<"请输入两个数";
double a,b;
cin>>a>>b;
cout<<a<<"+"<<b<<"="<<a+b<<endl;
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="3"||s=="减法"||s=="3.减法"){
cout<<"请输入两个数";
double a,b;
cin>>a>>b;
cout<<a<<"-"<<b<<"="<<a-b<<endl;
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="4"||s=="乘法"||s=="4.乘法"){
cout<<"请输入两个数";
double a,b;
cin>>a>>b;
cout<<a<<"*"<<b<<"="<<a*b<<endl;
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="5"||s=="除法"||s=="4.除法"){
cout<<"请输入两个数";
double a,b;
cin>>a>>b;
if(b==0){
error();
}
else{
cout<<a<<"/"<<b<<"="<<a/b<<endl;
cout<<"按Enter继续";
}
getchar();
getchar();
}
else if(s=="6"||s=="按位与"||s=="6.按位与"){
long long a,b;
cout<<"请输入两个数";
cin>>a>>b;
cout<<a<<"&"<<b<<"="<<(a&b)<<endl;
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="7"||s=="按位或"||s=="7.按位或"){
long long a,b;
cout<<"请输入两个数";
cin>>a>>b;
cout<<a<<"|"<<b<<"="<<(a|b)<<endl;
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="8"||s=="8.按位异或"||s=="8.按位异或"){
long long a,b;
cout<<"请输入两个数";
cin>>a>>b;
cout<<a<<"^"<<b<<"="<<(a^b)<<endl;
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="9"||s=="9.按位取反"||s=="按位取反"){
long long a;
cout<<"请输入一个数";
cin>>a;
cout<<"~"<<a<<"="<<(~a)<<endl;
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="10"||s=="10.逻辑与"||s=="逻辑与"){
long long a,b;
cout<<"请输入两个数";
cin>>a>>b;
cout<<a<<"&&"<<b<<"="<<(a&&b)<<endl;
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="11"||s=="11.逻辑或"||s=="逻辑或"){
long long a,b;
cout<<"请输入两个数";
cin>>a>>b;
cout<<a<<"||"<<b<<"="<<(a||b)<<endl;
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="12"||s=="12.逻辑非"||s=="逻辑非"){
long long a;
cout<<"请输入一个数";
cin>>a;
cout<<"!"<<a<<"="<<(!a)<<endl;
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="13"||s=="13.逻辑相等"||s=="逻辑相等"){
long long a,b;
cout<<"请输入两个数";
cin>>a>>b;
cout<<a<<"=="<<b<<"="<<(a==b)<<endl;
cout<<"按Enter继续";
getchar();
getchar();
}
else if(s=="14"||s=="14.进制转换"||s=="进制转换")jzzh();
else{
error();
}
}
else if(s=="4"||s=="虚拟机"||s=="4.虚拟机"){
if(vm){
cout<<"暂不支持多层虚拟机\n按Enter继续";
getchar();
}
else{
vm=true;
lastkj=kjdll;
kjdll+="_vm";
main();
vm=false;
kjdll=lastkj;
csh();
}
}
else if(s=="5"||s=="检测环境"||s=="5.检测环境"){
cout<<"1.检测当前在是否在虚拟机内\n2.内存测试";
getline(cin,s);
clear();
if(s=="1"||s=="检检测当前在是否在虚拟机内"||s=="1.检测当前在是否在虚拟机内"||s=="虚拟机检测"){
if(vm)cout<<"当前在虚拟机内";
else cout<<"当前不在虚拟机内";
cout<<"\n按Enter继续";
getchar();
}
else if(s=="2"||s=="内存测试"||s=="2.内存测试"){
ramtst(true);
}
else{
error();
}
}
else{
error();
}
}
else if(s=="2"||s=="电源"||s=="2.电源"){
cout<<"1.关闭LOS\n2.重新启动LOS\n";
getline(cin,s);
if(s=="1"||s=="关闭"||s=="关闭LOS"||s=="1.关闭LOS"){
return 0;
}
else if(s=="2"||s=="重启"||s=="重新启动"||s=="重新启动LOS"||s=="2.重新启动LOS"){
return 1;
}
else{
error();
}
}
else if(s=="3"||s=="设置"||s=="3.设置"){
cout<<"1.开关机/重启是否显示画面\n2.恢复出厂设置";
getline(cin,s);
clear();
if(s=="1"||s=="开关机/重启是否显示画面\n"||s=="1.开关机/重启是否显示画面\n"){
cout<<"0.显示\n1.不显示\n";
getline(cin,s);
FILE *kj=fopen(kjdll.c_str(),"w");
if(s=="0"||s=="0.显示"||s=="显示"){
fprintf(kj,"%d",0);
kjhm=0;
}
else if(s=="1"||s=="1.不显示"||s=="不显示"){
fprintf(kj,"%d",1);
kjhm=1;
}
else error();
clear();
fclose(kj);
}
else if(s=="2"||s=="恢复出厂设置"||s=="2.恢复出厂设置"){
cout<<"确定请输入1";
char c=getchar();
if(c=='1'){
FILE *kj=fopen(kjdll.c_str(),"w");
fprintf(kj,"%d",0);
fclose(kj);
gjff();
//cout<<"恢复完成!正在重启";
//Sleep(500);
return 1;
}
}
else{
error();
}
}
else{
error();
}
return 2;
}
void clear(){
system("cls");
clear_cin();
}
string getver(bool flag){
string a="LOS 2 Update 1 Version 2212_4TH(Build 2230)\n",b="编译日期2022/12/11\n按Enter继续";
if(flag){
cout<<a<<b;
getchar();
clear();
}
return a;
}
void startup(int type){
if(kjhm)return;
if(type==1||type==2){
shutdown(type);
return;
}
for(int i=1;i<=1;i++){
string s="\
\n\
\n\
\n\
\n\
\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
\n\
\n\
\n\
\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
\n\
\n\
\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
\n\
\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|_\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|__\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|___\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|____\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|_____\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|______\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|_______\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|________\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|_________\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|__________\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|___________\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|____________\n\n\n\n\n\n";
cout<<s;
cout<<" ";
cout<<"正在启动LOS";
Sleep(166);
clear();
}
Sleep(500);
}
void shutdown(int type){
if(kjhm)return;
for(int i=1;i<=1;i++){
string s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|____________\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|___________\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|__________\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|_________\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|________\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|_______\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|______\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|_____\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|____\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|___\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|__\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|_\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
|\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
|\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
|\n\
\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
|\n\
\n\
\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
|\n\
\n\
\n\
\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
|\n\
\n\
\n\
\n\
\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(60);
clear();
s="\
\n\
\n\
\n\
\n\
\n\
\n\
\n\n\n\n\n\n";
cout<<s;
cout<<" ";
if(type==1)cout<<"正在关闭LOS";
else cout<<"正在重新启动";
Sleep(166);
clear();
}
Sleep(500);
}
void s_d(int n){
Sleep(n);
cout<<".";
}
void error(string s){
clear();
cout<<s;
getchar();
}
void notebook(){
string s="",t="";
clear();
system("title LOS中的小小记事本");
cout<<"小小记事本1.0\n";
cout<<"编译日期:2022/11/28\n";
cout<<"按Ctrl+Z停止输入\n";
while(getline(cin,t)){
s+=t+'\n';
}
cin.clear();
cout<<"\n文件目录:";
string a;
getline(cin,a);
cout<<"\n文件名(加后缀名):";
string r;
getline(cin,r);
a+=r;
FILE* fp=fopen(a.c_str(),"w");
fprintf(fp,s.c_str());
fclose(fp);
cout<<"写入完成!";
Sleep(666);
}
void setname(){
string r="title "+getver(false);
system(r.c_str());
}
void csh(){
FILE* kj=fopen(kjdll.c_str(),"r");
fscanf(kj,"%d",&kjhm);
fclose(kj);
if(vm)return;
FILE* yc=fopen("YOS","w");
fprintf(yc,"%d",1);
fclose(yc);
}
void ramtst(bool flag){
p=(char*)malloc(157374182);
for(int j=0;j<157374182;j++)p[j]=1;
if(p!=NULL){
if(flag){
cout<<"测试成功,能够正常运行LOS!\n";
Sleep(1000);
}
}
else{
cout<<"错误:剩余内存过少,可能无法正常运行LOS!";
exit(1);
}
free(p);
clear();
}
int q(char number){
if(number<='9')return number-48;
return number-55;
}
int f(string a,int k){
int n=0;
for(int i=0;i<a.size();i++){
n=n*k+q(a[i]);
}
return n;
}
int n;
string s;
int jz;
char _p(int number){
if(number<10)return number+48;
return number+55;
}
string g(int n,int jz){
string s="";
while(n){
s=_p(n%jz)+s;
n/=jz;
}
return s;
}
void jzzh(){
cout<<"请输入需要转换的数的进制n";
cin>>n;
cout<<"请输入需要转换的数s";
cin>>s;
cout<<"请输入要转换到的进制";
cin>>jz;
int ans=f(s,n);
cout<<g(ans,jz);
}
void gtuser(){
FILE * usnmfp=fopen("usnum","r");
FILE * usfp=fopen("user","r");
fscanf(usnmfp,"%d",&n);
for(int i=2;i<=n;i++){
fscanf(usfp,"%s%s",&user[i][0],&user[i][1]);
}
n++;
}
void login(){
if(n==1){
if(user[1][1]=="")return;
cout<<"Welcome,"<<user[1][0]<<"!";
Sleep(500);
return;
}
//cout<<"请选择用户"
}
void gjff(){
FILE* yc=fopen("YOS","w");
fprintf(yc,"%d",0);
fclose(yc);
}
void read_YOS(){
FILE * yc=fopen("YOS","r");
int eeeee=0;
fscanf(yc,"%d",&eeeee);
Sleep(500);
if(eeeee==1){
last_normal_shutdown();
}
fclose(yc);
}
void last_normal_shutdown(){
cout<<"**提示:上一次未正常关闭LOS,可能会出现异常\n";
cout<<"恢复出厂设置输入1,否则输入其它字符\n";
char c=getchar();
clear();
if(c=='1'){
FILE *kj=fopen(kjdll.c_str(),"w");
fprintf(kj,"%d",0);
fclose(kj);
gjff();
cout<<"恢复完成!";
Sleep(500);
clear();
return;
}
clear();
}
欢迎加入洛谷团:
LOS官方开发团队 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
李承耀在2022-12-21 14:44:59追加了内容
快点,谁回答谁采纳