2016-05-27 5 views
-1
if (SuperTotal [0] == SuperTotal [1] && SuperTotal [0] == SuperTotal [2]) 
    { 
     System.out.println ("1First: " + name [0] + ", " + name [1] + ", " + name [2]); 
    } 
    //1=2 & 1 > 3 
    else if (SuperTotal [0] == SuperTotal [1] && SuperTotal [0] > SuperTotal [2]) 
    { 
     System.out.println ("2First: " + name [0] + ", " + name [1] + "\nSecond: " + name [2]); 
    } 
    //2=3 & 2 > 1 
    else if (SuperTotal [1] == SuperTotal [2] && SuperTotal [1] > SuperTotal [0]) 
    { 
     System.out.println ("3First: " + name [1] + ", " + name [2] + "\nSecond: " + name [0]); 
    } 
    //1=3 & 1 > 2 
    else if (SuperTotal [0] == SuperTotal [2] && SuperTotal [0] > SuperTotal [1]) 
    { 
     System.out.println ("4First: " + name [0] + ", " + name [2] + "\nSecond: " + name [1]); 
    } 
    //1=2 & 1 < 3 
    else if (SuperTotal [0] == SuperTotal [1] && SuperTotal [0] < SuperTotal [2]) 
    { 
     System.out.println ("5First: " + name [2] + "'nSecond: " + name [0] + ", " + name [1]); 
    } 
    //1=3 & 1 < 2 
    else if (SuperTotal [0] == SuperTotal [2] && SuperTotal [0] < SuperTotal [1]) 
    { 
     System.out.println ("7First: " + name [0] + "\nSecond: " + name [1] + ", " + name [2]); 
    } 
    //2=3 & 2 < 1 
    else if (SuperTotal [1] == SuperTotal [2] && SuperTotal [1] < SuperTotal [0]) 
    { 
     System.out.println ("7First: " + name [0] + "\nSecond: " + name [1] + ", " + name [2]); 
    } 
    else if (SuperTotal [0] > SuperTotal [1] && SuperTotal [0] > SuperTotal [2] && (SuperTotal [1] < SuperTotal [2] || SuperTotal [1] > SuperTotal [2])) 
    { 
    } 

Standard, auch wenn verschiedene Nummern gegeben, die verschiedene „if“ Anweisungen wird standardmäßig die man verwenden sollte, die 2 = 3 1.Meine if-Anweisungen wird aus irgendeinem Grund Also im Grunde auf die falsche

sagt

Sehen Sie irgendetwas, was ich falsch mache, oder etwas, das effizienter durchgeführt werden könnte?

+0

die Zufallszahlen in dem System.out.printin(); um sicherzustellen, dass die richtige ausgegeben wird. –

+1

Ich bin sicher, dass es effizienter gemacht werden kann (Programmierer-weise). Ich habe keine Ahnung wie, zumindest nicht bevor du erklärst, was du zu tun versuchst (in Worten) - weil ich nicht wirklich die Geduld habe, den repetitiven Code mit winzigen Variationen zu lesen. – Amadan

+0

Was ist im SuperTotal Array gespeichert? – Abhishek

Antwort

0

für // 1 = 3 2 Ausgangsnamen sind falsch

else if (SuperTotal [0] == SuperTotal [2] && SuperTotal [0] < SuperTotal [1]) 
{ 
    System.out.println ("7First: " + name [1] + "\nSecond: " + name [0] + ", " + name [2]); 
} 
+0

Vielen Dank dafür. Das hätte ich wahrscheinlich nie gesehen. :) –

Verwandte Themen