#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cctype>
#include<sstream>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<map>
#include<cstdlib>
#include<limits>
#include<bits/stdc++.h>
#include<windows.h>
#include<time.h>
#include<conio.h>
#include<bits/stdtr1c++.h>
#include<alg.h>
#include<qedit.h>
#include<stdio.h>
#include<cstdio>         
#include<cstring>
#include<fstream>
using namespace std;
#define int long long
void sout(string s){
	for(int i=0;i<s.size();i++){
		cout<<s[i];
		cout.flush();
		Sleep(40);
	}
	cout<<"\n";
	Sleep(100);
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	while(1){
		sout("请输入名字密码!\n");
		sout("请按照\n/register 名字 密码 密码\n来注册!\n");
		sout("如果已有账号,请按照\n/login 名字 密码\n来登录已有的账号!\n");
		string s,s1,s2,s3;
		cin>>s;
		if(s=="/register"){
			cin>>s1>>s2>>s3;
			if(s2!=s3){
				sout("密码不统一!请重新输入!\n");
			}else{
				sout("注册成功!\n");
				ofstream MC("MineCraft.txt",ios::app);
				MC<<"名字:"<<s1<<" 密码:"<<s2<<"\n";
				MC.close();
				system("pause");
				system("cls");
			}
		}else if(s=="/login"){
			cin>>s1>>s2;
			ifstream fin("MineCraft.txt");
			string line;
			bool ok=0;
			while(getline(fin,line)){
				if(line.find("名字:"+s1)!=string::npos&&line.find("密码:"+s2)!=string::npos){
					ok=1;
					break;
				}
			}
			fin.close();
			if(ok){
				sout("登录成功!欢迎回来!");
				break;
			}else{
				sout("没有找到名字或者输入错误!\n请重新尝试!");
			}
		}else{
			sout("没有找到名字或者输入错误!\n请重新尝试!");
			system("pause");
			system("cls");
		}
		system("cls");
	}
	system("cls");
	sout("欢迎来到MC极限生存!");
	
	return 0;
}

名字和密码会保存到代码保存的地方! 把最后一句删掉就可以再写其他东西了!

1 条评论

  • @ 2026-5-4 13:43:29

    乐猫腾跃团队创作

    • 1