Witam wszystkich.
Chciałbym zapytać co myślicie o moim kodzie.
Znalazłem i wykorzystałem gotową funkcję Math.max(int a, int b).
System.out.println(Math.max(Math.max(Math.max(a, b),c),d));
Hello all.
I would like to ask what you think about my code.
I found and used the ready Math.max function (int a, int b).
System.out.println(Math.max(Math.max(Math.max(a, b),c),d));
Czy można zastosować taki kod? Can such a code be used?
W trakcie dyskusji
Komentarze (2)
- Popularne
- Nowe
- Najstarsze
Musisz być zalogowany aby dodać komentarz
Mateusz Kulec
17 maja 2020, 21:07
BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
String liczba1 = reader.readLine();
int a = Integer.parseInt(liczba1);
String liczba2 = reader.readLine();
int b = Integer.parseInt(liczba2);
String liczba3 = reader.readLine();
int c = Integer.parseInt(liczba3);
String liczba4 = reader.readLine();
int d = Integer.parseInt(liczba4);
if ( a >= b && a >= c && a >= d)
{
System.out.println(a);
}
if ( b > a && b >= c && b >= d)
{
System.out.println(b);
}
if ( c > b && c > a && c >= d)
{
System.out.println(c);
}
if ( d > b && d > c && d > a)
{
System.out.println(d);
}
0
Attila
2 maja 2020, 22:35
You can use any method to make the code work. Actually it is (or will be very soon) required for you to look up solutions for yourself, and it will involve methods which you were not introduced to in this course.
0