回 帖 发 新 帖 刷新版面

主题:我需要高手指点下~~看下这个简单程序

帮忙注解下  我是新手  看不懂  最好是一个一个的分析  好让我学习


#include"conio.h"
#include"iostream.h"
#include"string.h"
int main()
{
    char pd[100]="                    ";
    char pass[]="123456";//默认密码
    int nowpos =0;
    cout<<"input the password:"<<endl;
    cout.flush();
    char ch=_getch();
    
    while(ch!=13)
    {
        if(ch==8)
        {
            if(nowpos>0)
            {
                nowpos--;
                cout<<char(8)<<' '<<char(8);
                cout.flush();
            }
        }
        else
        {
            pd[nowpos]=ch;
            cout<<"*";
            cout.flush();
            nowpos++;
        }
        ch=_getch();
    }
    if(strncmp(pd,pass,strlen(pass))==0&&nowpos==strlen(pass))
    {
        cout<<endl<<"rignt!"<<endl;
        cout<<"1.XXXX,2.XXXXX choose one"<<endl;
L:        cin>>ch;
        if(ch==1)
        {
            //add your code here
        }
        else if(ch==2)
        {
            //add your code here
        }
        else
        {
            cout<<"please choose 1 or 2!"<<endl;
            goto L;
        }
    }
    else
    {
        cout<<endl<<"wrong! over"<<endl;
    }
    

    return 0;
}

回复列表 (共1个回复)

沙发

又是这种问题,老大

我来回复

您尚未登录,请登录后再回复。点此登录或注册