爱问知识人 爱问教育 医院库

求助:编写口令检查程序

首页

求助:编写口令检查程序

编写口令检查程序,正确口令为hello。
1、若输入正确,提示“You are welcome”,程序结束。
2、若不正确,提示“Wrong password!”,同时检查口令是否已输3次,若未,提示“Enter again:”,且允许再输入口令,若已输入3次,则提示“You have entered three times!You are not welcome!”,且不允许用户再输入口令,结束程序。

提交回答
好评回答
  • 2013-01-10 18:02:24
    #include  
    #include  
    void main() 
    { 
    int i = 1; 
    char str[20]; 
    printf("Enter password:"); 
    gets(str); 
    while ((i < 3) && (strcmp(str, "hello") != 0)) 
    { 
    i++; 
    printf("Wrong password! Enter again:"); 
    gets(str); 
    } 
    if (strcmp(str, "hello") == 0) 
    printf("You are welcome!\n"); 
    else 
    printf("Wrong password! You have entered three times! You are not welcome!\n"); 
    } 
    

    大***

    2013-01-10 18:02:24

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 171-190
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):