public int getMax(int a, int b, int c) { return a>b && a>c ? a : b > c ? b : c; }返回三个数中,最大的一个
public int MaxNumber(int a, int b, int c) { if (a > b && a > c) { return a; } else if (b > a && b > c) { return b; } else { return c; } }
private int getMax(int a, int b, int c) { int[] array=new int[]{a,b,c}; Array.Sort(array); return array[array.Length-1]; } 返回最大的那个
using System; using System.Collections.Generic; using System.Text;namespace CompareValue { class Program { static void Main(string[] args) { int a = 1, b = 2, c = 3; Console.WriteLine(a > b && a > c ? a : b > c ? b : c); Console.ReadKey(); } public int getMax(int a, int b, int c) { return a > b && a > c ? a : b > c ? b : c; } } }
using System; using System.Collections.Generic; using System.Text;namespace CompareValue { class Program { static void Main(string[] args) { int a = 1, b = 2, c = 3; Console.WriteLine(a > b && a > c ? a : b > c ? b : c); Console.ReadKey(); } } }10楼代码有垃圾,看现在的
int[] arr = new int[] { 20, 1, 15 }; var max = from n in arr orderby n select n; foreach (var n in max) { Console.WriteLine(n.ToString()); } /* 1 15 20 请按任意键继续. . . */
{
return a>b && a>c ? a : b > c ? b : c;
}返回三个数中,最大的一个
{
if (a > b && a > c)
{
return a;
}
else if (b > a && b > c)
{
return b;
}
else
{
return c;
}
}
{
int[] array=new int[]{a,b,c};
Array.Sort(array);
return array[array.Length-1]; }
返回最大的那个
using System;
using System.Collections.Generic;
using System.Text;namespace CompareValue
{
class Program
{
static void Main(string[] args)
{
int a = 1, b = 2, c = 3;
Console.WriteLine(a > b && a > c ? a : b > c ? b : c);
Console.ReadKey();
}
public int getMax(int a, int b, int c)
{
return a > b && a > c ? a : b > c ? b : c;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;namespace CompareValue
{
class Program
{
static void Main(string[] args)
{
int a = 1, b = 2, c = 3;
Console.WriteLine(a > b && a > c ? a : b > c ? b : c);
Console.ReadKey();
}
}
}10楼代码有垃圾,看现在的
var max = from n in arr orderby n select n;
foreach (var n in max)
{
Console.WriteLine(n.ToString());
}
/*
1
15
20
请按任意键继续. . .
*/