跳到正文

闲话

模仿DOS

yjm131206Minecraft约 19 分钟
原文
文章信息与版本

文章信息

收录
2026年2月7日
更新
2026年7月30日
篇幅
约 19 分钟
获赞
1

版本

  1. v2当前
  2. v1

我是一个想要写系统的人,最近学了循环等,不费话,上代码

C++
#include <bits/stdc++.h>
using namespace std;

int main()
{
	const string USER;
	const string PASSWORD;
	string user8, pasw8;
	cout << "loading..." << endl;
	cout << "Press any key to Setup" << endl;
	string s;
	cin >> s;
	cout << endl << "Starting MS-DOS 1.0.2..." << endl;
	system ( "color 17" );
	cout << "MS-DOS Setup " << endl << "============" << endl;
	cout << "Welcome to Setup!" << endl;
	cout << "Setup is Starting..." << endl;
	for ( int i = 1; i <= 100; i ++ )
	{
		cout << "Setup is fixed " << i << "%" << endl;
	}
	while ( 1 )
	{
		cout << "Please scan the User and Password" << endl;
		string user, pasw;
		cout << "Username----------->";
		cin >> user;
		cout << "Password----------->";
		cin >> pasw;
		const string USER = user;
		const string PASSWORD = pasw;
		cout << "Please scan the User and Password again" << endl;
		string user2, pasw2;
		cout << "Username----------->";
		cin >> user2;
		cout << "Password----------->";
		cin >> pasw2;
		if ( user2 == USER )
		{
			if ( pasw2 == PASSWORD )
			{
				cout << "OK!Thanks!" << endl;
				user8 = USER;
				pasw8 = PASSWORD;
				break;
			}
			else
			{
				cout << "Password Error!" << endl;
				continue;
			}
		}
		else
		{
			cout << "Username Error!" << endl;
			continue;
		}
	}
	system ( "color 07" );
	for ( int i = 0; i <= 100; i ++ )
	{
		cout << "Reading File" << i << "%" << endl;
	}
	cout << "Restarting..." << endl;
	string m;
	cout << "loading..." << endl;
	cout << "starting MS-DOS..." << endl;
	string user3, pasw3;
	while ( 1 )
	{
		const string USER = user8;
		const string PASSWORD = pasw8;
		cout << "Please scan the User and Password" << endl;
		string user2, pasw2;
		cout << "Username----------->";
		cin >> user2;
		cout << "Password----------->";
		cin >> pasw2;
		if ( user2 == USER )
		{
			if ( pasw2 == PASSWORD )
			{
				cout << "OK!Thanks!" << endl;
				break;
			}
			else
			{
				cout << "Password Error!" << endl;
				continue;
			}
		}
		else
		{
			cout << "Username Error!" << endl;
			continue;
		}
	}
	cout << "Welcome to MS-DOS!" << endl; 
	while ( 1 )
	{
		string m;
		cout << "C:\\";
		cout << ">";
		getline ( cin, m );
		if ( m == "dir" )
		{
			system ( "dir" );
		}
		else if ( m == "shutdown/s" )
		{
			cout << "shutting down... "<< endl;
			return 0;
		}
			else if ( m == "shutdown/r" )
			{
				cout << "restarting..." << endl;
				cout << "loading..." << endl;
				cout << "starting MS-DOS..." << endl;
				cout << "Welcome to MS-DOS!" << endl;
				continue;
			}
				else if ( m == "help" )
				{
					system ( "help" );
					cout << "( scan log off can log off your user)" << endl;
				}
					else if ( m == "VER" || m == "ver" )
					{
						cout << "MS-DOS Vesion:1.0.2" << endl; 
					}
						else if ( m == "Minecraft.exe" )
						{
							cout << "error! Minecraft.exe is (x32), but system is (x16)." << endl;
						}
							else if ( m == "Windows11" )
							{
								cout << "loading..." << endl;
								cout << "Starting Windows" << endl;
								system ( "color 17" );
								{
									cout << ":(                                      " << endl;
									cout << "  你的电脑出现了某些问题,需要重新启动。" << endl;
									cout << "我们只是寻找错误信息,然后为你重新启动。" << endl;
									cout << "丨一一丨如有更多了解," << endl;
									cout << "丨一一丨请访问http://www.windows.com" << endl;
								}
								cout << "loading..." << endl;
								cout << "starting MS-DOS..." << endl;
								cout << "Welcome to MS-DOS!" << endl;
								continue;
							}
								else if ( m == "Dev-C++.exe" )
								{
									cout << "can't write C++!" << endl;
								}
									else if ( m == "vol" )
									{
										system ( "vol" );
									}
										else if ( m == "winver" )
										{
											cout << "This computer intsalled Windows is :" << system ( "ver" ) << system ( "winver" ) << endl;
										}
											else if ( m == "log off" )
											{
												cout << "logging off..." << endl;
												while ( 1 )
												{
													const string USER = user8;
													const string PASSWORD = pasw8;
													cout << "Please scan the User and Password" << endl;
													string user2, pasw2;
													cout << "Username----------->";
													cin >> user2;
													cout << "Password----------->";
													cin >> pasw2;
													if ( user2 == USER )
													{
														if ( pasw2 == PASSWORD )
														{
															cout << "OK!Thanks!" << endl;
															break;
														}
														else
														{
															cout << "Password Error!" << endl;
															continue;
														}
													}
													else
													{
														cout << "Username Error!" << endl;
														continue;
													}
												}
												continue;
											}
												else if ( m == "Update" )
												{
													cout << "New Edition : MS-DOS 1.1.0" << endl;
													cout << "Do you want update? (Y/N) " << endl;
													string h;
													cin >> h;
													if ( h == "Y" || h == "y" )
													{
														cout << "Ok!" << endl;
														cout << "Reading updates..." << endl;
														for ( int i = 1; i <= 100; i ++ )
														{
															cout << "Fixed" << i << "%" << endl;
														}
														cout << "Complete!" << endl;
														for ( int i = 1; i <= 100; i ++ )
														{
															cout << "Update fixed" << i << "%" << endl;
														}
														cout << "Update complete!" << endl;
														cout << "Restarting..." << endl;
														break;
													}
											}
													else
													{
														cout << "haven't'" << m << "'flie" << endl;
													}
		
	}
	while ( 1 )
	{
		const string USER = user8;
		const string PASSWORD = pasw8;
		cout << "Please scan the User and Password" << endl;
		string user2, pasw2;
		cout << "Username----------->";
		cin >> user2;
		cout << "Password----------->";
		cin >> pasw2;
		if ( user2 == USER )
		{
			if ( pasw2 == PASSWORD )
			{
				cout << "OK!Thanks!" << endl;
				break;
			}
			else
			{
				cout << "Password Error!" << endl;
				continue;
			}
		}
		else
		{
			cout << "Username Error!" << endl;
			continue;
		}
	}
	cout << "Welcome to MS-DOS!" << endl; 
	while ( 1 )
	{
		string m;
		cout << "C:\\";
		cout << ">";
		getline ( cin, m );
		if ( m == "dir" )
		{
			system ( "dir" );
		}
		else if ( m == "shutdown/s" )
		{
			cout << "shutting down... "<< endl;
			break;
		}
			else if ( m == "shutdown/r" )
			{
				cout << "restarting..." << endl;
				cout << "loading..." << endl;
				cout << "starting MS-DOS..." << endl;
				cout << "Welcome to MS-DOS!" << endl;
				continue;
			}
				else if ( m == "help" )
				{
					system ( "help" );
					cout << "( scan log off can log off your user)" << endl;
				}
					else if ( m == "VER" || m == "ver" )
					{
						cout << "MS-DOS Vesion:1.1.0" << endl; 
					}
						else if ( m == "Minecraft.exe" )
						{
							cout << "error! Minecraft.exe is (x32), but system is (x16)." << endl;
						}
							else if ( m == "Windows11" )
							{
								cout << "loading..." << endl;
								cout << "Starting Windows" << endl;
								system ( "color 17" );
								{
									cout << ":(                                      " << endl;
									cout << "  你的电脑出现了某些问题,需要重新启动。" << endl;
									cout << "我们只是寻找错误信息,然后为你重新启动。" << endl;
									cout << "丨一一丨如有更多了解," << endl;
									cout << "丨一一丨请访问http://www.windows.com" << endl;
								}
								cout << "loading..." << endl;
								cout << "starting MS-DOS..." << endl;
								cout << "Welcome to MS-DOS!" << endl;
								continue;
							}
								else if ( m == "Dev-C++.exe" )
								{
									cout << "can't write C++!" << endl;
								}
									else if ( m == "vol" )
									{
										system ( "vol" );
									}
										else if ( m == "winver" )
										{
											cout << "This computer intsalled Windows is :" << system ( "ver" ) << system ( "winver" ) << endl;
										}
											else if ( m == "log off" )
											{
												cout << "logging off..." << endl;
												while ( 1 )
												{
													const string USER = user8;
													const string PASSWORD = pasw8;
													cout << "Please scan the User and Password" << endl;
													string user2, pasw2;
													cout << "Username----------->";
													cin >> user2;
													cout << "Password----------->";
													cin >> pasw2;
													if ( user2 == USER )
													{
														if ( pasw2 == PASSWORD )
														{
															cout << "OK!Thanks!" << endl;
															break;
														}
														else
														{
															cout << "Password Error!" << endl;
															continue;
														}
													}
													else
													{
														cout << "Username Error!" << endl;
														continue;
													}
												}
												continue;
											}
												else if ( m == "Update" )
												{
													cout << "Your PC is New Edition Now!" << endl;
												}
													else
													{
														cout << "haven't'" << m << "'flie" << endl;
													}
		
	}
	return 0;
}
原文
存档评论2 条抓取于