代码改变世界

随笔档案-2012年10月8日

19.从Email中提取用户名和域名:abc@163.com

2012-10-08 11:07 by 飞鸟爱巢, 1033 阅读, 收藏,
摘要: string s = Console.ReadLine(); int atindex=s.IndexOf('@'); string username = s.Substring(0, atindex); string domain = s.Substring(atindex + 1); Console.WriteLine("用户名是:{0},域名是{1}", username, domain); 阅读全文

18,接收用户输入的一句英文,将其中的单词以反序输出。“hello c sharp”-"sharp c hello"

2012-10-08 10:57 by 飞鸟爱巢, 1406 阅读, 收藏,
摘要: string s = Console.ReadLine(); string[] words = s.Split(' '); for (int i = words.Length - 1; i >= 0; i--) { Console.Write(words[i]+' '); } 阅读全文

17.接收用户输入的字符串,将其中的字符以与输入相反的顺序输出。“abc”-"cba"

2012-10-08 10:42 by 飞鸟爱巢, 713 阅读, 收藏,
摘要: string s = Console.ReadLine(); for (int i = s.Length - 1; i >= 0; i--) { Console.Write(s[i]); } 阅读全文

4. 提示用户输入年龄,如果大于等于18,则告知用户可以查看,如果小于10岁,则告知不允许查看,如果大于等于10岁,则提示用户是否继续查看(yes,no),如果输入的是yes则提示用户可以查看,否则提示不可以查看。

2012-10-08 10:00 by 飞鸟爱巢, 2250 阅读, 收藏,
摘要: Console.WriteLine("请输入年龄:"); string s = Console.ReadLine(); int age=Convert.ToInt32(s); if (age>=18) { Console.WriteLine("可以查看!"); } else if (age>=10&&age<18) { Console.WriteLine("是否继续查看,继续查看请输入“yes”,不查看请输入“no”!"); string a=Console.ReadLine(); if (a == 阅读全文

3. 提示用户输入用户名,然后再提示输入密码,如果用户名是“admin”并且密码是“888888”则提示正确,否则提示错误,如果用户名不是admin还提示用户用户名不存在。

2012-10-08 09:49 by 飞鸟爱巢, 1923 阅读, 收藏,
摘要: Console.WriteLine("请输入用户名:"); string username = Console.ReadLine(); Console.WriteLine("请输入密码:"); string password = Console.ReadLine(); if (username=="admin"&&password == "888888") { Console.WriteLine("用户名密码正确!"); } if (username != "admin 阅读全文

2. 提示用户输入密码,如果密码是“888888”则提示正确,否则要求再输入一次,如果密码是“888888”则提示正确,否则提示错误。

2012-10-08 09:38 by 飞鸟爱巢, 904 阅读, 收藏,
摘要: Console.WriteLine("请输入密码:"); string password = Console.ReadLine(); if (password == "888888") { Console.WriteLine("密码正确!"); } else{ Console.WriteLine("请重新输入密码:"); password = Console.ReadLine(); if (password == "888888") { Console.WriteLine("密码正确! 阅读全文

1. 提示用户输入密码,如果密码是“888888”则提示正确,否则提示错误。

2012-10-08 09:28 by 飞鸟爱巢, 653 阅读, 收藏,
摘要: Console.WriteLine("请输入密码"); string password = Console.ReadLine(); if (password == "888888") { Console.WriteLine("密码正确!"); } else { Console.WriteLine("密码错误!"); } Console.ReadKey(); 阅读全文