using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _0821汪敏 { class Program { static void Main(string[] args) { /*int t = 0;//计数器 for (int i = 0; i <= 200; i++) { if (i % 7 == 0 && i % 4 != 0) { Console.Write(i + "\t"); t++; if (t % 6 == 0) Console.WriteLine(); } } int i;//循环控制变量 double score; double sum=0; Console.WriteLine("请输入10个学生的成绩"); for (i = 0; i < 10;i++ ) {//重复输入 score = Convert.ToDouble(Console.ReadLine()); sum = sum + score; } Console.WriteLine("这些学生的平均分为"+sum/(i-1)); char an; Console.WriteLine("练习的怎么样(y/n)"); an = Convert.ToChar(Console.ReadLine()); while(an!='y') { Console.WriteLine("早上练习"); Console.WriteLine("上午练习"); Console.WriteLine("下午练习"); Console.WriteLine("晚上练习"); an = Convert.ToChar(Console.ReadLine()); } Console.WriteLine("你好棒");*/ string an; Console.WriteLine("请输入密码"); an =(Console.ReadLine()); while (an != "jzit") { Console.WriteLine("请输入密码"); an = (Console.ReadLine()); } Console.WriteLine("-欢迎进入系统-"); } } }
一个循环的案例
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { //int n; //int sum = 0; //Console.WriteLine("请输入n的值"); //n = Convert.ToInt32(Console.ReadLine()); //for (int i = n; i <= 10; i++) //{ // sum = sum + i; //} //Console.WriteLine("若干个数的和为" + sum); //int i = n; //do //{ // sum = sum + i; // i++; //} //while (i <= 10); //Console.WriteLine("若干个数的和为"+sum); //while (i <= 10) //{ // sum = sum + i; // i++; //} //Console.WriteLine("若干个数的和为" + sum); //string password; //Console.WriteLine("请输入密码"); //password = Console.ReadLine(); //while (password != "jzit") //{ // Console.WriteLine("请输入正确密码"); // password = Console.ReadLine(); //} //Console.WriteLine("--------------"); //Console.WriteLine("*欢迎进入系统*"); //Console.WriteLine("--------------"); //double shu, sum = 0; //Console.WriteLine("请输入数"); //shu = Convert.ToDouble(Console.ReadLine()); //while (shu != -1) //{ // sum = sum + shu; // Console.WriteLine("请继续输入数"); // shu = Convert.ToDouble(Console.ReadLine()); //} //Console.WriteLine("这几个数的和为" + sum); //int n; //for (n = 1; n <= 100; n++) //{ // if(n % 3 == 0 && n % 8 == 0) continue; // Console.Write(n + "\t"); //} string password; int i; Console.WriteLine("请输入密码"); password = Console.ReadLine(); for (i = 2; i > -1; i--) { if (password == "12345") { Console.WriteLine("--------------"); Console.WriteLine("-欢迎进入系统-"); Console.WriteLine("--------------"); break; } if (i == 0) { Console.WriteLine("对不起,你已经没有机会"); break; } else { Console.WriteLine("密码输入错误,你还有" + i + "次机会,请重新输入"); password = Console.ReadLine(); } } } } }
标签:Console,int,System,Generic,循环,WriteLine,using From: https://www.cnblogs.com/bky-wang/p/18124607