==================카운트 만들기
1. while 구문으로 만들은것
class FlowEx19 { public static void main(String[] args) { int i = 10; while(i >= 0){ System.out.println(i); for (int j =0; j <1000000000 ;j++ ) { ; } i--; } System.out.println("완료"); } } |
2. for문으로 만들기
class Cho { public static void main(String[] args) { for (int i = 10 ; i >=0 ; i-- ) { System.out.println(i); for (int j = 0; j < 1000000000 ; j++ ) { ; } } } } |
======================로또 for문으로 출력해보기
문장1
class For { public static void main(String[] args) { int temp = 0; int a[] = new int[45]; int k = 0; for (int i = 0; i < 45 ; i++ ) { a[i] = i + 1; } for (int y = 0; y < 100 ; y++ ) { k = (int)(Math.random()*45); temp = a[0]; a[0] = a[k]; a[k] = temp; } for (int i =0; i <= 6 ; i++ ){ System.out.print(a[i]+" "); } } } |
문장2
class Tee { public static void main(String[] args) { int a = 0; for (int i = 0; i < 6 ; i++){ a = (int)(Math.random()*45)+1; System.out.print(a + "\t" ); } } } |
================시작과 끝 시간 currentTimeMillis 이용하여출력하여라
class Tee { public static void main(String[] args) { long cc = System.currentTimeMillis(); int a = 0; for (int i = 0; i < 6 ; i++){ a = (int)(Math.random()*45)+1; System.out.print(a + "\t" ); } long ccq = System.currentTimeMillis(); System.out.println("시작" + cc); System.out.println("끝" + ccq); System.out.println("걸린시간" + " " +(ccq - cc)); } } |
===========if 문성적표만들기
class If { public static void main(String [] args){ int a = 100; String b =""; if (a >= 100){ b = "A"; if (a >= 95){ b += "+"; } } else { b ="B"; } System.out.println(b); } } |