2016a
(Различия между версиями)
Antonk (обсуждение | вклад) (→Ввод с клавиатуры) |
Antonk (обсуждение | вклад) (→Ввод с клавиатуры) |
||
Строка 1: | Строка 1: | ||
== Ввод с клавиатуры == | == Ввод с клавиатуры == | ||
− | import java.io.BufferedReader; | + | <pre> |
− | import java.io.IOException; | + | import java.io.BufferedReader; |
− | import java.io.InputStreamReader; | + | import java.io.IOException; |
− | + | import java.io.InputStreamReader; | |
− | public class Main { | + | |
− | public static void main(String[] args) throws NumberFormatException, IOException { | + | public class Main { |
− | int a, b; | + | public static void main(String[] args) throws NumberFormatException, IOException { |
− | + | int a, b; | |
− | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | + | |
− | + | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
− | a = Integer.parseInt(br.readLine()); | + | |
− | b = Integer.parseInt(br.readLine()); | + | a = Integer.parseInt(br.readLine()); |
− | + | b = Integer.parseInt(br.readLine()); | |
− | System.out.println(a+b); | + | |
− | }< | + | System.out.println(a+b); |
− | <br | + | } |
− | }< | + | |
+ | } | ||
+ | </pre> | ||
+ | |||
+ | == Функции == | ||
+ | |||
+ | <pre> | ||
+ | import java.io.BufferedReader; | ||
+ | import java.io.IOException; | ||
+ | import java.io.InputStreamReader; | ||
+ | |||
+ | public class Main { | ||
+ | |||
+ | public static void main(String[] args) throws NumberFormatException, IOException { | ||
+ | int a, b, c; | ||
+ | double d; | ||
+ | |||
+ | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
+ | |||
+ | a = Integer.parseInt(br.readLine()); | ||
+ | b = Integer.parseInt(br.readLine()); | ||
+ | |||
+ | c = sum(a, b); | ||
+ | |||
+ | d = mySqrt(b); | ||
+ | |||
+ | System.out.println(c); | ||
+ | System.out.println(d); | ||
+ | } | ||
+ | |||
+ | public static double mySqrt(int a) { | ||
+ | return Math.sqrt(a); | ||
+ | } | ||
+ | |||
+ | public static int sum(int a, int b) { | ||
+ | System.out.println("I really want to sleep"); | ||
+ | return a+b; | ||
+ | } | ||
+ | |||
+ | public static int max2(int a, int b) { | ||
+ | if (a > b) { | ||
+ | return a; | ||
+ | } else { | ||
+ | return b; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </pre> |
Версия 09:10, 29 ноября 2012
Ввод с клавиатуры
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { int a, b; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); a = Integer.parseInt(br.readLine()); b = Integer.parseInt(br.readLine()); System.out.println(a+b); } }
Функции
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { int a, b, c; double d; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); a = Integer.parseInt(br.readLine()); b = Integer.parseInt(br.readLine()); c = sum(a, b); d = mySqrt(b); System.out.println(c); System.out.println(d); } public static double mySqrt(int a) { return Math.sqrt(a); } public static int sum(int a, int b) { System.out.println("I really want to sleep"); return a+b; } public static int max2(int a, int b) { if (a > b) { return a; } else { return b; } } }