IF的使用

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace 第四个程序
 8 {
 9   class Program
10   {
11     static void Main(string[] args)
12     {
13 
14       Console.WriteLine("请输入密码");
15       string password = Console.ReadLine();
16       if (password == "888")
17         {
18           Console.WriteLine("密码正确");
19         }
20       else
21         {
22           Console.WriteLine("请重新输入");
23           password = Console.ReadLine();
24           if (password == "888")
25           {
26             Console.WriteLine("密码正确");
27           }
28           else
29           {
30             Console.WriteLine("程序错误");
31           }
32         }
33       Console.WriteLine("程序结束");
34       Console.ReadKey();
35 
36     }
37   }
38 }

 

 

运行效果:

posted @ 2015-11-20 03:02  翻滚吧炒鸡蛋  阅读(221)  评论(0编辑  收藏  举报