C语言
方法一:
使用条件语句逐一比较
```c
include int main() { int a, b, c; printf("请输入三个数\n"); scanf("%d %d %d", &a, &b, &c); if (a >= b) { if (a >= c) { printf("最大数是 %d", a); } else { printf("最大数是 %d", c); } } else { if (b >= c) { printf("最大数是 %d", b); } else { printf("最大数是 %d", c); } } return 0; } ``` 定义比较函数 ```c include int MaxNum(int a, int b) { return a > b ? a : b; } int MinNum(int a, int b) { return a < b ? a : b; } int main() { int a, b, c, max, min; printf("请输入三个数字大小不同的数字,以空格分隔:"); scanf("%d %d %d", &a, &b, &c); max = MaxNum(MaxNum(a, b), c); min = MinNum(MinNum(a, b), c); printf("%d %d %d", max, a + b + c - max - min, min); return 0; } ``` Java 使用`Scanner`类接收输入并进行比较 ```java import java.util.Scanner; public class Test15 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("输入第一个数字:"); int x = sc.nextInt(); System.out.print("输入第二个数字:"); int y = sc.nextInt(); System.out.print("输入第三个数字:"); int z = sc.nextInt(); int min = x; int mid; if (y < min) { min = y; } if (z < min) { min = z; } if (y > max) { max = y; } if (z > max) { max = z; } mid = x + y + z - min - max; System.out.println("三个数字由小到大排列为: " + min + "<" + mid + "<" + max); } } ``` 使用`Math.max`方法 ```java import java.util.Scanner; public class Test15 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("请依次输入三个整数:a,b,c(以空格隔开)"); int a = scanner.nextInt(); int b = scanner.nextInt(); int c = scanner.nextInt(); scanner.close(); int max = Math.max(Math.max(a, b), c); System.out.println("最大值为 " + max); } } ``` Python Python中可以使用内置的`max`函数来比较三个整数 ```python a = int(input("请输入第一个数值:")) b = int(input("请输入第二个数值:")) c = int(input("请输入第三个数值:")) max_value = max(a, b, c) print("最大值为", max_value) ``` 这些方法涵盖了不同编程语言中比较三个整数的常见做法,可以根据具体需求和编程环境选择合适的方法。方法二:
方法一:
方法二: