using System; public class Test { public static void Main() { int x; int y; int z; Console.WriteLine ("请输入三个数:"); x=int.Parse (Console.ReadLine ()); y=int.Parse (Console.ReadLine ()); z=int.Parse (Console.ReadLine ()); if(x>y) { if(x>z) { Console.WriteLine ("{0},{1},{2}",x,y,z); } else Console.WriteLine ("{0},{1},{2}",z,y,x); } else { if(y>z) { Console.WriteLine ("{0},{1},{2}",y,z,x);
} else { Console.WriteLine ("{0},{1},{2}",z,y,x); } } } }
using System; public class Test { public static void Main() { int x; int y; int z; Console.WriteLine ("请输入三个数:"); x=int.Parse (Console.ReadLine ()); y=int.Parse (Console.ReadLine ()); z=int.Parse (Console.ReadLine ()); if(x>y) { if(x>z) { Console.WriteLine ("{0},{1},{2}",x,y,z); } else Console.WriteLine ("{0},{1},{2}",z,y,x); } else { if(y>z) { Console.WriteLine ("{0},{1},{2}",y,z,x);
} else { Console.WriteLine ("{0},{1},{2}",z,y,x); } } } }
我试了下。不是很全面。改了一下,我的书写格式很烂的。 if(x>y) { if(y>z) {Console.WriteLine("{0},{1},{2}",x,y,z);} else if(y<z) {Console.WriteLine("{0},{1},{2}",x,z,y);} else if(x<z) {Console.WriteLine("{0},{1},{2}",z,x,y);} } else if(x<y) { if(x>z) {Console.WriteLine("{0},{1},{2}",y,x,z);} else if(x<z) {Console.WriteLine("{0},{1},{2}",y,z,x);} else if(y<z) { Console.WriteLine("{0},{1},{2}",z,y,x); } }