你要用什么语言啊,我用C语言给你写把
#include
void main()
{
int a[3];
int t,cc=0;
printf("请输入三个整数:\n");
for(int i=0;i<=2;i++)
scanf("%d",&a[i]);
for(i=0;i<2;i++)
{
for(j=i+1;j<3;j++)
{
if(a[i]>a[j])
{t=a[i];a[i]=a[j];a[j]=t;cc++;}
c++;
}
}
printf("结果是:")
for(int i=0;i<=2;i++)
printf("%d\n",a[i]);
}
给你来个java的:
package ch3;
import java.util.Scanner;
public class lx4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("请输入三个数:");
int x = in.nextInt(),y = in.nextInt(), z = in.nextInt();
if(x >= y && x >= z) {
if(y >= z) System.out.println(x+">"+y+">"+z);
else System.out.println(x+">"+z+">"+y);
}
if(y >= x && y >= z) {
if(x >= z) System.out.println(y+">"+x+">"+z);
else System.out.println(y+">"+z+">"+x);
}
if(z >= x && z >= y) {
if(x >= y) System.out.println(z+">"+x+">"+y);
}
else System.out.println(z+">"+y+">"+x);
}
}
你要用什么语言啊,我用C语言给你写把
#include
void
main()
{
int
a[3];
int
t,cc=0;
printf("请输入三个整数:\n");
for(int
i=0;i<=2;i++)
scanf("%d",&a[i]);
for(i=0;i<2;i++)
{
for(j=i+1;j<3;j++)
{
if(a[i]>a[j])
{t=a[i];a[i]=a[j];a[j]=t;cc++;}
c++;
}
}
printf("结果是:")
for(int
i=0;i<=2;i++)
printf("%d\n",a[i]);
}
vb写的
Dim a As Long
Dim b As Long
Dim c As Long
a = Val(InputBox("请输入整数"))
b = Val(InputBox("请输入整数"))
c = Val(InputBox("请输入整数"))
If a > b Then
If a > c Then
If b > c Then
Print a
Print b
Print c
Else
Print a
Print c
Print b
End If
Else
Print c
Print a
Print b
End If
Else
If b > c Then
If a > c Then
Print b
Print a
Print c
Else
Print b
Print c
Print a
End If
Else
Print c
Print b
Print a
End If
End If