求三个整数的最大值



Problem Description
请编写程序,输入三个整数,求出其中的最大值输出。
Input
在一行上输入三个整数,整数间用逗号分隔。
Output
输出三个数中的最大值。
Sample Input
5,7,9
Sample Output
max=9
Hint
Source

wy

[java]  view plain  copy
  1. import java.util.Scanner;  
  2. //import java.text.DecimalFormat;  
  3. public class Main {  
  4.     public static void main(String args[]) {  
  5.     Scanner cin = new Scanner(System.in);  
  6.    //DecimalFormat df = new DecimalFormat("0.00");  
  7.     int a, b, t, c;  
  8.     String ch = cin.nextLine();  
  9.     String array[] = ch.split(",");//将字符串以逗号为界分离储存在数组中  
  10.     a = Integer.parseInt(array[0]);//将数组中的值提出出来  
  11.     b = Integer.parseInt(array[1]);  
  12.     c = Integer.parseInt(array[2]);  
  13.     if(a > b && a > c)  
  14.     {  
  15.         t = a;  
  16.     }  
  17.     else if(b > a && b > c)  
  18.     {  
  19.         t = b;  
  20.     }  
  21.     else  
  22.     {  
  23.         t = c;  
  24.     }  
  25.     System.out.println("max=" + t);  
  26.     cin.close();  
  27.     }  
  28. }  
  29.    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值