jash.liao的JAVA整理教學:JAVA控制結構-迴圈(for)
jash.liao的JAVA整理教學:JAVA控制結構-迴圈(for)
線上執行:http://www.tutorialspoint.com/compile_java_online.php / http://www.compilejava.net/
code2html:http://tohtml.com/
publicclass HelloWorld{
publicstaticvoid main(String[]args){ int sum =0; int i;
for(i =1; i <=100; i++){ sum += i; }
System.out.println("1 + 2 + .... + 99 + 100 = "+ sum); } }
|