(신입사원채용무료교육, 오라클SQL, 튜닝, 힌트,자바프레임워크, 안드로이드, 아이폰, 닷넷)
class Sum {
long hab(int value) {
if(value == 0) return 0;
else return value+hab(value-1);
}
public static void main(String[] args) {
if (args.length<1) {
System.out.println("Usage : java Sum number ");
System.exit(1);
}
long time = System.currentTimeMillis();
int value = Integer.parseInt(args[0]);
Sum s = new Sum();
long hab = s.hab(value);
System.out.println("1부터 " + value + " 까지 합 = " + hab);
System.out.println("총 소요시간 : " + (System.currentTimeMillis()-time) + " millis");
Runtime r = Runtime.getRuntime();
long t = r.totalMemory();
long f = r.freeMemory();
System.out.println("총 메모리 : " + t + " bytes");
System.out.println("남은 메모리 : " + f + "bytes");
}
}
if(value == 0) return 0;
else return value+hab(value-1);
}
public static void main(String[] args) {
if (args.length<1) {
System.out.println("Usage : java Sum number ");
System.exit(1);
}
long time = System.currentTimeMillis();
int value = Integer.parseInt(args[0]);
Sum s = new Sum();
long hab = s.hab(value);
System.out.println("1부터 " + value + " 까지 합 = " + hab);
System.out.println("총 소요시간 : " + (System.currentTimeMillis()-time) + " millis");
Runtime r = Runtime.getRuntime();
long t = r.totalMemory();
long f = r.freeMemory();
System.out.println("총 메모리 : " + t + " bytes");
System.out.println("남은 메모리 : " + f + "bytes");
}
}
댓글 없음:
댓글 쓰기