Erinevus lehekülje "ITI0011:Kordamine eksamiks" redaktsioonide vahel
Mine navigeerimisribale
Mine otsikasti
84. rida: | 84. rida: | ||
} | } | ||
+ | } | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | <pre> | ||
+ | public class Hello { | ||
+ | public static int y = 1, x = 100; | ||
+ | |||
+ | public static void main(String[] args) { | ||
+ | int x = 0; | ||
+ | int z = x + 0; | ||
+ | |||
+ | System.out.println("main x,y,z: " + x + " " + y + " " + z); | ||
+ | z = world(hello(x), y); | ||
+ | System.out.println("main x,y,z: " + x + " " + y + " " + z); | ||
+ | } | ||
+ | |||
+ | public static void hello(int x, int z) { | ||
+ | x = z + 100; | ||
+ | System.out.println("hello(world(x, z))"); | ||
+ | } | ||
+ | |||
+ | public static int hello(int x) { | ||
+ | int y = 0; | ||
+ | ++x; | ||
+ | while (x < 100) { | ||
+ | if (y > 2) | ||
+ | continue; | ||
+ | break; | ||
+ | } | ||
+ | System.out.println("hello x,y: " + (x - 2) + " " + y); | ||
+ | return x; | ||
+ | } | ||
+ | |||
+ | public static int world(int x, int z) { | ||
+ | int y = 0; | ||
+ | y++; | ||
+ | while (y++ <= 3) | ||
+ | z *= y; | ||
+ | System.out.println("world x,z++,z: " + x + " " + z + " " + z); | ||
+ | return z; | ||
+ | } | ||
} | } | ||
</pre> | </pre> |
Redaktsioon: 5. jaanuar 2015, kell 07:33
Koodilugemine
public class First { public static int a = 5; public static int x = 10; public static void main(String[] args) { a = x; x++; int aa = a; int y = x() + a(x) + x(x(aa)); System.out.println("main a:" + a + " x:" + x); System.out.println("y:" + y); int a = 2 * 4; for (int i = a; i - 2 > 5 / 2; ) { System.out.println(i); a += i--; } System.out.println("a:" + a); String s = "taskuuni"; String result = ""; for (a = 2; a < 4; a += 1) { result = s.substring(a, 2 * a) + result; } System.out.println(result); System.out.println(s.charAt(2) + result.substring(1)); } public static int x() { return a + 1; } public static int a(int a) { //a = a++ + 1; a = a + 2; System.out.println(a); for (int x = 0; a < 1; a++) ; System.out.println("a a:" + a + " x:" + x); return 0; } public static int x(int x) { x++; a--; System.out.println("x a:" + a + " x:" + x); return x; } }
public class ReadME{ public static void main(String[] args) { int sum = 0; for (int i = 0, j = 0; i++ < 5 ; i--) { sum += i++; } System.out.println(sum); sum = 0; for (int i = 0, j = 0; i++ < 5 ; i--, j-=2) { sum += i++ + j++; } System.out.println(sum); int u = 13; for (int i = u / 2; i++ < 12; i += 2) { u += i; } System.out.println("u:" + u); int sum = 0; for (int i = 0; i < 5; i++) { if (i % (i % 3 + 1) == 1) continue; sum += i; } } }
public class Hello { public static int y = 1, x = 100; public static void main(String[] args) { int x = 0; int z = x + 0; System.out.println("main x,y,z: " + x + " " + y + " " + z); z = world(hello(x), y); System.out.println("main x,y,z: " + x + " " + y + " " + z); } public static void hello(int x, int z) { x = z + 100; System.out.println("hello(world(x, z))"); } public static int hello(int x) { int y = 0; ++x; while (x < 100) { if (y > 2) continue; break; } System.out.println("hello x,y: " + (x - 2) + " " + y); return x; } public static int world(int x, int z) { int y = 0; y++; while (y++ <= 3) z *= y; System.out.println("world x,z++,z: " + x + " " + z + " " + z); return z; } }