解题思路,这题C为什么等于17?public Class XXX{public static void main(String args「」)int a=9,b=3,c=17,t;if(a>b){t=a;a=b;b=t;}if(a>c){t=a;a=c;c=t;}if(b>c){t=b;b=c;c=t;}System.out.println("a="+a,"b="+b,"c="+c);}}
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/05 14:53:13
adWD"I4ٸ'!T"HǢÛ{sq{rL_dHSf~9
解题思路,这题C为什么等于17?public Class XXX{public static void main(String args「」)int a=9,b=3,c=17,t;if(a>b){t=a;a=b;b=t;}if(a>c){t=a;a=c;c=t;}if(b>c){t=b;b=c;c=t;}System.out.println("a="+a,"b="+b,"c="+c);}}
解题思路,这题C为什么等于17?
public Class XXX
{
public static void main(String args「」)
int a=9,b=3,c=17,t;
if(a>b)
{t=a;a=b;b=t;}
if(a>c)
{t=a;a=c;c=t;}
if(b>c)
{t=b;b=c;c=t;}
System.out.println("a="+a,"b="+b,"c="+c);
}
}
解题思路,这题C为什么等于17?public Class XXX{public static void main(String args「」)int a=9,b=3,c=17,t;if(a>b){t=a;a=b;b=t;}if(a>c){t=a;a=c;c=t;}if(b>c){t=b;b=c;c=t;}System.out.println("a="+a,"b="+b,"c="+c);}}
public Class XXX
{
public static void main(String args「」)
int a=9,b=3,c=17,t;
if(a>b)
{t=a;a=b;b=t;} //如果a>b 则交换两数 所以此时a=3 b=9 c=17
if(a>c)
{t=a;a=c;c=t;} //如果a>c 则交换两数 不满足 所以不交换
if(b>c)
{t=b;b=c;c=t;} //如果b>c 则交换两数 不满足 所以不交换
System.out.println("a="+a,"b="+b,"c="+c); //最后输出a=3 b=9 c=17
}
}
--------------------------------------------------------