C++模拟Windows系统(第3集)

Hello!我是老六工作室,今天我们来编辑设置的部分。

我们可以使用自定义函数,叫setting。

上自定义函数的代码:

int setting()
{
	cout<<"设置 Setting"<<endl;
	cout<<"1:停止运行Windows C++"<<endl;
	cout<<"2:参数"<<endl;
	cout<<"3:关闭设置"<<endl;
	int a;
	cin>>a;
	switch (a)
	{
		case 1:
			{
				cout<<"停止Windows C++运行中...";
				_sleep(1000);
				return 0;
			}
		case 2:cout<<"【老六工作室】制作"<<endl;
	}
	return 0;
}

看看我们的程序:

#define n1 532
#define D 250
#include<iostream>
#include<windows.h>
using namespace std;
void sound()
{
	Beep(n1,D);
}
int setting()
{
	cout<<"设置 Setting"<<endl;
	cout<<"1:停止运行Windows C++"<<endl;
	cout<<"2:参数"<<endl;
	cout<<"3:关闭设置"<<endl;
	int a;
	cin>>a;
	switch (a)
	{
		case 1:
			{
				cout<<"停止Windows C++运行中...";
				_sleep(1000);
				return 0;
			}
		case 2:cout<<"【老六工作室】制作"<<endl;
	}
	return 0;
}
int main()
{
	system("title Windows C++");
	cout<<"Opening";
	cout<<".";
	_sleep(100);
	cout<<".";
	_sleep(100);
	cout<<".";
	_sleep(100);
	string username;
	cout<<endl;
	cout<<"欢迎使用~"<<endl;
	cout<<"[初始化1/2]请输入用户名:";
	cin>>username;
	string password;
	cout<<"[初始化2/2]请输入密码:";
	cin>>password;
	int len=password.length();
	//这里,我们用了length函数求密码长度
	if(len<6)
	{
		cout<<"请重新输入(6位以上):";
		cin>>password;
	}
	return 0;
}

(下一集我会改一下设置密码,变成while循环,谢谢C++小盆友的建议)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值