::  ::  ::  ::  :: 管理

密码输入匹配

Posted on 2008-06-15 13:12 nt05 阅读(169) 评论(0)  编辑 收藏 引用 所属分类: cpp
#include < iostream.h >
#include
< conio.h >
#include
< stdio.h >
#include
< string .h >

int  main()
{
 
char  name[ 20 ]; 
 cout
<< " your name: " << endl;
 gets(name);
 cout
<< " your password: " << endl;
 
char  password[ 20 ];
 
char  s[ 20 ] = { ' 8 ' , ' 5 ' , ' 4 ' , ' 2 ' } ;
 
int  i = 0 ;
 
while ( 1 )
    
{    
        password[i]
= getch();
        cout
<< ' * ' << flush;
        
if (password[i] == 13 || i > 8 )
         

           password[i]
= ' \0 ' ;
           cout
<< " \n " ;
           
break ;
         }
  
        i
++ ;
    }

 
if ((strcmp(s,password)) == 0 )
     cout
<< " 密码正确 " << endl;
 
else
     cout
<< " 密码错误 " << endl;
  
 
return   0 ;