public class _05_For {
public static void main(String[] args) {
//๋ฐ๋ณต๋ฌธ FOR
System.out.println("์ด์์ค์ธ์. ๋์ฝ์
๋๋ค");
for (int i =0;i<10;i++){
//System.out.println("์ด์์ค์ธ์. ๋์ฝ์
๋๋ค. "+i);
System.out.println("ํ์ํฉ๋๋ค. ๋์ฝ์
๋๋ค. "+i);
}
//์ง์๋ง ์ถ๋ ฅ(for i ๋ง ์ ๊ณ ์ํฐ)
//0, 2, 4, 6, 8
for (int i =0; i<10 ; i += 2){
System.out.print(i);
}
System.out.println();
//ํ์๋ง ์ถ๋ ฅ(for i ๋ง ์ ๊ณ ์ํฐ)
//1, 3, 5, 7, 9
for (int i =1; i<10 ; i += 2){
System.out.print(i);
}
//๊ฑฐ๊พธ๋ก ์ซ์
//5, 4, 3, 2, 1
for (int i =5; i>0 ; i--){
System.out.print(i);
}
//1๋ถํฐ 10๊น์ง์ ์๋ค์ ํฉ
//1 + 2 + 3 + .... + 10 = 55
int sum = 0;
for (int i=1; i<=10; i++){
sum += i;
System.out.println("ํ์ฌ ๊น์ง ์ดํฉ์ " + sum);
}
System.out.println("1๋ถํฐ 10๊น์ง ์ดํฉ์ " + sum);
}
}