336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
package com.tistory.tansanc; import java.util.Scanner; public class Test { public static void main(String[] args) { int[] timeTable = new int[25]; timeCheck(timeTable); int inputLength; int[][] inputData; Scanner sc = new Scanner(System.in); inputLength = sc.nextInt(); inputData = new int[inputLength][2]; for (int inputFor = 0; inputFor < inputLength; inputFor++) { inputData[inputFor][0] = sc.nextInt(); // Start Time inputData[inputFor][1] = sc.nextInt(); // End Time } for (int inputFor = 0; inputFor < inputLength; inputFor++) { for (int todayCheck = inputData[inputFor][0]; todayCheck < inputData[inputFor][1]; todayCheck++) timeTable[todayCheck] = 1; } timeCheck(timeTable); int maxBreak = 0; int maxTime = 0; int maxTempTime = 0; for (int inputFor = 0; inputFor < 25; inputFor++) { if( timeTable[inputFor] == 1) { maxTempTime++; } else { if ( maxTempTime > maxTime) { maxTime = maxTempTime; } maxTempTime = 0; } } if ( maxTempTime > maxTime) { maxTime = maxTempTime; } System.out.println("maxTime : " + maxTime); } static void timeCheck(int[] timeTable) { for (int i = 0; i < timeTable.length; i++) System.out.printf("%3d ", i); System.out.print("\n"); for (int i = 0; i < timeTable.length; i++) System.out.printf("%3d ", timeTable[i]); System.out.print("\n"); System.out.print("\n"); } }
'Programming > JAVA,JSP' 카테고리의 다른 글
Java 채팅 소스 예제 #1 (0) | 2016.02.04 |
---|---|
Java CardLayout Test (0) | 2016.01.26 |
Java Server/Client Code (2) | 2015.11.12 |
[Spring] 한글 인코딩 설정 (0) | 2015.10.29 |
mysql table datetime tip (0) | 2014.10.20 |