Return to Snippet

Revision: 62550
at March 13, 2013 00:11 by Kollins


Updated Code
import java.util.Scanner;

public class Cviceni­3{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        System.out.println("Zadej postupne 3 ci­sla, po kazdemm stiskni ENTER");
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a > b){
            if(b > c){
                System.out.println("Poradi­: "+a+" "+b+" "+c);
            }

        }else{      //(b > a)
            if(a > c){
                System.out.println("Poradi­: "+b+" "+a+" "+c);
            }else{
                if(c > b){
                    System.out.println("Poradi: "+c+" "+b+" "+a);
                }
            }
        }if(a > c){
            if(c > b){
                System.out.println("Poradi­: "+a+" "+c+" "+b);
            }
        }else{  //(c > a)
            if(a > b){
                System.out.println("Poradi: "+c+" "+a+" "+b);
            }else{
                if(b > c){
                    System.out.println("Poradi­: "+b+" "+c+" "+a);
                }
            }
        }
    }
}

Revision: 62549
at March 2, 2013 14:40 by Kollins


Updated Code
import java.util.Scanner;

public class Cvi�ení3{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        System.out.println("Zadej postupn� t�i �ísla, po každém stiskni ENTER");
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a > b){
            if(b > c){
                System.out.println("Po�adí: "+a+" "+b+" "+c);
            }

        }else{      //(b > a)
            if(a > c){
                System.out.println("Po�adí: "+b+" "+a+" "+c);
            }else{
                if(c > b){
                    System.out.println("Po�adí: "+c+" "+b+" "+a);
                }
            }
        }if(a > c){
            if(c > b){
                System.out.println("Po�adí: "+a+" "+c+" "+b);
            }
        }else{  //(c > a)
            if(a > b){
                System.out.println("Po�adí: "+c+" "+a+" "+b);
            }else{
                if(b > c){
                    System.out.println("Po�adí: "+b+" "+c+" "+a);
                }
            }
        }
    }
}

Revision: 62548
at March 1, 2013 00:21 by Kollins


Initial Code
import java.util.Scanner;

public class Cvičení3{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        System.out.println("Zadej postupně tři čísla, po každém stiskni ENTER");
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a > b){
            if(b > c){
                System.out.println("Pořadí: "+a+" "+b+" "+c);
            }

        }else{      //(b > a)
            if(a > c){
                System.out.println("Pořadí: "+b+" "+a+" "+c);
            }else{
                if(c > b){
                    System.out.println("Pořadí: "+c+" "+b+" "+a);
                }
            }
        }if(a > c){
            if(c > b){
                System.out.println("Pořadí: "+a+" "+c+" "+b);
            }
        }else{  //(c > a)
            if(a > b){
                System.out.println("Pořadí: "+c+" "+a+" "+b);
            }else{
                if(b > c){
                    System.out.println("Pořadí: "+b+" "+c+" "+a);
                }
            }
        }
    }
}

Initial URL


Initial Description
Napište program, který seřadí (3) zadaná čísla podle velikosti od největšího po nejmenší.

(Pzn.: šlo by pravděpodobně řešit mnohem lépe než je uvedeno)

Initial Title
Pořadí čísel podle velikosti

Initial Tags


Initial Language
Java