用java 从键盘输入3个整数,分别赋给整数变量a b c 然后将输入的整数按照从小到大的顺序放在变量abc中,并

用java
从键盘输入3个整数,分别赋给整数变量a b c 然后将输入的整数按照从小到大的顺序放在变量a b c中,并输三个变量的值。(各种情况都要算啊)最好源代码粘贴,复制到Eclipse
就可以用
要输入啊!!a=b呢 b=c呢或c=a呢还有a=b=c

2L你好夸张!
把下面代码放到main()方法中
Scanner s=new Scanner(System.in);
System.out.println("请输入a的值:");
int a=s.nextInt();
System.out.println("请输入b的值:");
int b=s.nextInt();
System.out.println("请输入c的值:");
int c=s.nextInt();
int x=0;
if(a>b)
{
x=a;
a=b;
b=x;
}
if(a>c)
{
x=a;
a=c;
c=x;
}
if(b>c)
{
x=b;
b=c;
c=x;
}
System.out.println(a+","+b+","+c);
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-04-17
package com.zhidao.test;

public class OrderNum {

public void orderValue(int x, int y, int z) {
int a;
int b;
int c;
if (x > y && x > z) {
c = x;
if (y > z) {
a = z;
b = y;
} else {
a = y;
b = z;
}
} else if (x < y && x < z) {
a = x;
if (y > z) {
b = z;
c = y;
} else {
b = y;
c = z;
}
} else {
b = x;
if (y > z) {
a = z;
c = y;
} else {
a = y;
c = z;
}
}
System.out.println("a = "+a+"; b = "+b+"; c = "+c);
}

public static void main(String[] args)
{
OrderNum on=new OrderNum();
on.orderValue(1, 2, 3);
on.orderValue(3, 2, 1);
on.orderValue(1, 3, 2);
on.orderValue(2, 3, 1);
on.orderValue(2, 1, 3);
on.orderValue(3, 1, 2);
}
}
第2个回答  2011-04-17
public class Test {
public static void main(String args[]){
int a,b,c;
a=Integer.parseInt(args[0]);
b=Integer.parseInt(args[1]);
c=Integer.parseInt(args[2]);

int []result=new int[3];
if(a>=b){
if(a>=c){
result[0]=a;
if(b>=c){
result[1]=b;
result[2]=c;
}else{
result[1]=c;
result[2]=b;
}
}else{
result[0]=c;
result[1]=a;
result[2]=b;
}
}else {
if(c>=b){
result[0]=c;
result[1]=b;
result[2]=a;
}else{
result[0]=b;
if(a>=c){
result[1]=a;
result[2]=c;
}else{
result[1]=c;
result[2]=a;
}
}
}

a=result[2];
b=result[1];
c=result[0];

System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}
第3个回答  2011-04-17
从键盘输入3个整数,分别赋给整数变量a b c 然后将输入的整数按照从小到大的顺序放在变量a b c中,并输三个变量的值。(各种情况都要算啊)最好源代码粘贴,复制到Eclipse
第4个回答  2011-04-18
public static void sortInt(int a, int b, int c)
{
int temp = 0;
if (a > b)
{
temp = b;
b = a;
a = temp;
}
if (b > c)
{
temp = c;
c = b;
b = temp;
}
if (a > b)
{
temp = b;
b = a;
a = temp;
}
System.out.println(a + "-" + b + "-" + c);
}

用java 从键盘输入3个整数,分别赋给整数变量a b c 然后将输入的整数按...
int b=s.nextInt();System.out.println("请输入c的值:");int c=s.nextInt();int x=0;if(a>b){ x=a;a=b;b=x;} if(a>c){ x=a;a=c;c=x;} if(b>c){ x=b;b=c;c=x;} System.out.println(a+","+b+","+c);...

用java 从键盘输入3个整数,分别赋给整数变量a b c 然后将输入的整数按...
import java.util.Scanner;public class TestSort { public static void main(String[] args){ Scanner sc = new Scanner(System.in);System.out.println("请输入数字a");int a = sc.nextInt();System.out.println("请输入数字b");int b = sc.nextInt();System.out.println("请输入数字c"...

...赋给整型变量a,b,c,然后将输入的整数按照从小到大的顺序放在变量a,b...
int a,b,c;int m;\/\/中间变量 \/\/输入 if(a>b){ \/\/a比b大则a b交换 m=b;b=a;a=m;} if(a>c){ \/\/a比c大则ac交换 m=c;c=a;a=m;} if(b>c){ \/\/b比c大则bc交换 m=b;b=c;c=m;}

...赋给整型变量abc然后将输入的整数按照从小到大的顺序放在变量abc并...
a:b):c;\/\/找出a,b,c中最小值赋值给min b=a+b+c-max-min;\/\/三个数的和减去最大值和最小值,结果就是中间值 a = min;\/\/最小值赋值给a c = max;\/\/最大值赋值给c System.out.println(a + "-" + b + "-" + c);\/\/输出abc } ...

输3个整数,分别赋值给int变量a,b,c,再将输入的整数从小到大的放在变量...
import java.util.Scanner;public class TestForQ { public static void main(String[] args){ int a = 0;int b = 0;int c = 0;Scanner sc = new Scanner(System.in);a = sc.nextInt();b = sc.nextInt();c = sc.nextInt();if (a > b) { int temp = a;a = b;b = ...

在java中怎么比较三个整数大小例如(a , b, c);并从小到大输出
用冒泡排序,对三个数字按照由小到大进行排序。以23、11、17为例,代码如下:import java.util.Scanner;public class woo { static int[] bubbleSort(int[] date) { boolean isSwap;for(int j = 1; j < date.length; j++) { isSwap = false;for(int i = 0; i < date.length - j;...

用java.随机输入3个数a,b,c,按大小顺序输出。
public static void main(String[] args) { System.out.print("请输入三个数,用空格分开:");Scanner sc = new Scanner(System.in);int[] a = new int[3];for (int i = 0; i < 3; i++) { a[i] = sc.nextInt();} int temp = 0;if (a[0] < a[1]) { temp = a[0...

...分别赋值产量a b c 然后将输入的整数按照从小到大
function onsubmit(){ \/\/方法一:window.location="\/servlet"\/\/servlet的链接 \/\/方法二 window.open("\/servlet");\/\/方法三 objXMLReq = new ActiveXObject("Microsoft.XMLHTTP");objXMLReq.open("POST", "\/servet", true);objXMLReq.setRequestHeader("User-Agent", "Microsoft.XMLHTTP");obj...

设计一个java程序,从键盘输入三个整数,按照从小到大的顺序输出
import java.io.InputStreamReader;public class Test { public static void main(String args[]) { System.out.println("请输入三个数,使用','分隔:");BufferedReader br = new BufferedReader(new InputStreamReader(System.in));try { String tempString = "";while (null != (tempString =...

java 编写一个程序,输入3个整数,然后程序将对这三个整数按照从大到小...
Scanner in=new Scanner(System.in);int c=in.nextInt();然后对三个数进行比较。int tmp=0;if(a<b){ tmp=a;a=b;b=tmp;} if(a<c){ tmp=a;a=c;c=tmp;} if(b<c){ tmp=b;b=c;c=tmp;} System.out.println(a+" "+b+" "+c);这就可以了,自己想想动动脑子才能灵活运用,...

相似回答