public class Ex1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Exercise1完成");
}
}
|
a = 5
b = 4
c = 3
public class Ex3 {
/**
* @param args
*/
public static void main(String[] args) {
int a, b, c, d;
a = 17;
b = 12;
c = 21;
System.out.println("17と12の最大値:" + max(a, b));
d = max(max(a, b), c);
System.out.println("17と12と21の最大値:" + d);
}
public static int max(int x, int y) {
if (x > y) return x;
return y;
}
}
|
public class Ex4 {
/**
* @param args
*/
public static void main(String[] args) {
int x;
int y;
x = 20;
y = f(x);
System.out.println("第20項は" + y);
}
public static int f(int n) {
if (n == 1) return 1;
return 2 * f(n - 1) + 3;
}
}
|