using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace _5_3 { class Program { static void Main(string[] args) { string strA, strB; int i; bool bA; i = 0; bA = true; Console.WriteLine("请输入字符串1:"); strA = Console.ReadLine(); Console.WriteLine("请输入字符串2:"); strB = Console.ReadLine(); Console.WriteLine("----------------------------------------"); while (i < strA.Length && i < strB.Length) { if (strA[i] > strB[i]) { Console.WriteLine("字符串{0} 大于 字符串{1}", strA, strB); Console.WriteLine("----------------------------------------"); Console.ReadKey(); return; } if (strA[i] < strB[i]) { Console.WriteLine("字符串{0} 小于 字符串{1}", strA, strB); Console.WriteLine("----------------------------------------"); Console.ReadKey(); return; } i++; } if (i < strB.Length) { Console.WriteLine("字符串{0} 小于 字符串{1}", strA, strB); Console.WriteLine("----------------------------------------"); Console.ReadKey(); return; } if (i < strA.Length) { Console.WriteLine("字符串{0} 大于 字符串{1}", strA, strB); Console.WriteLine("----------------------------------------"); Console.ReadKey(); return; } Console.WriteLine("字符串{0} 等于 字符串{1}", strA, strB); Console.WriteLine("----------------------------------------"); Console.ReadKey(); } } }