|
本帖最后由 航空兔子 于 2013-10-18 18:48 编辑
我又来了......
某程序员叔叔叫我多用程序解决实际问题
于是密码系统就诞生了......
大家可以参考参考
32位EXE&源码下载:
http://yunpan.cn/QbbXrntK5ZMyT
C++源码:
[code=Cpp width=740px]
#include <iostream>
#include <stdlib.h>
#include <conio.h>
using namespace std;
const unsigned short digit=6; //在此设置密码位数
bool dec(bool *x)
{
short o;
for(o=0;o<digit+1;++o){if(!x[o]){return false;}}
return true;
}
int main()
{
system("TITLE 密码系统 By 航空兔子");
short i=-1,o;
char password[digit+1]="123456",ch; //在此设置密码
bool key[digit];
for(o=0;o<digit;++o){key[o]=true;}
cout<<"输入密码:";
while(1)
{
if(kbhit())
{
if((ch=getch())=='\r')
{
cout<<endl;
if(dec(key)&&(i==(digit-1))){cout<<"密码正确!\n";break;}
else{cout<<"密码错误!\n";break;}
}
else
{
if(ch=='\b')
{
if(i>-1)
{
key=true;
--i;
cout<<"\b \b";
}
}
else
{
++i;
cout<<"*";
if(i<digit)
{
if(ch!=password){key=false;}
}
}
}
}
}
system("pause");
return 0;
}
[/code] |
|