No older revisions available
No older revisions available
Score 문제 보기
----
(zeropage)코드레이스출동 연습
----
프로그래밍
----
~java import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class Score { public void readFile() { try { BufferedReader br = new BufferedReader(new FileReader("test.txt")); String line = br.readLine(); int testCase = Integer.parseInt(line); for(int i = 0; i < testCase; i++) { line = br.readLine(); int result = processOneCase(line); System.out.println(result); } br.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } private int processOneCase(String line) { String [] group = line.split("X"); int count = 1; int sum = 0; for(String each : group) { int size = each.length(); for(int i = 0; i < size; i++) { sum += (i+1); } } return sum; } public static void main(String[] args) { Score s = new Score(); s.readFile(); } }----
(zeropage)코드레이스출동 연습
프로그래밍