#10951

import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a,b;
		String line;
		while((line=br.readLine())!=null) {
			StringTokenizer st = new StringTokenizer(line);
			a = Integer.parseInt(st.nextToken());
			b = Integer.parseInt(st.nextToken());
			System.out.println(a+b);
		}

	}
}

#10952

import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		int a,b;
		StringTokenizer st = new StringTokenizer(br.readLine());
		a = Integer.parseInt(st.nextToken());
		b = Integer.parseInt(st.nextToken());
		System.out.println(a+b);
		while ((a+b)!=0){
			st = new StringTokenizer(br.readLine());
			a = Integer.parseInt(st.nextToken());
			b = Integer.parseInt(st.nextToken());
			if ((a+b)!=0){
				System.out.println(a+b);
			}
		}
		bw.flush();
		bw.close();
	}
}

위 를 좀더 정리...

import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		int a,b;

		while(true) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			a = Integer.parseInt(st.nextToken());
			b = Integer.parseInt(st.nextToken());
			if ((a+b)==0){
				break;
			}
			System.out.println(a+b);
		}
		bw.flush();
		bw.close();

	}
}

'알고리즘 > acmicpc.net' 카테고리의 다른 글

#10039  (0) 2020.07.13
1110  (0) 2020.07.10
10871  (0) 2020.07.08
2439  (0) 2020.07.08
11022  (0) 2020.07.08
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		String line1 = br.readLine();
		String line2 = br.readLine();
		int N = Integer.parseInt(line1.split(" ")[0]);
		int X = Integer.parseInt(line1.split(" ")[1]);
		String[] arr = line2.split(" ");
		int target;
		for (int i=0; i<N; i++){
			target = Integer.parseInt(arr[i]);
			if (target < X){
				bw.write(target + " ");
			}
		}
		
		bw.flush();//남아있는 데이터를 모두 출력시킴
		bw.close();//스트림을 닫음
	}
}

'알고리즘 > acmicpc.net' 카테고리의 다른 글

1110  (0) 2020.07.10
10951&10952  (0) 2020.07.10
2439  (0) 2020.07.08
11022  (0) 2020.07.08
11021.  (0) 2020.07.08

별 순차

import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int cnt = Integer.parseInt(br.readLine());
		for(int i=1; i<=cnt; i++){
			for(int j=1; j<=i; j++){
				bw.write("*");
			}
			bw.write("\n");
		}
		bw.flush();//남아있는 데이터를 모두 출력시킴
		bw.close();//스트림을 닫음
	}
}

별 우측정렬

import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int cnt = Integer.parseInt(br.readLine());

		for(int i=0; i<cnt; i++){
			for(int j=1; j<(cnt-i); j++){
				bw.write(" ");
			}
			for(int j=0; j<=i; j++) {
				bw.write("*");
			}
			bw.newLine();
		}
		bw.flush();//남아있는 데이터를 모두 출력시킴
		bw.close();//스트림을 닫음
	}
}

'알고리즘 > acmicpc.net' 카테고리의 다른 글

10951&10952  (0) 2020.07.10
10871  (0) 2020.07.08
11022  (0) 2020.07.08
11021.  (0) 2020.07.08
2741. N찍 & 2742.N반대로찍  (0) 2020.07.08
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int cnt = Integer.parseInt(br.readLine());
		int a,b;
		for (int i=1; i<=cnt ; i++){
			String line = br.readLine();
			StringTokenizer st = new StringTokenizer(line, " ");
			a=Integer.parseInt(st.nextToken());
			b=Integer.parseInt(st.nextToken());
			bw.write("Case #" + i + ": "+a +" + " + b + " = " + (a+b) +"\n");
		}
		bw.flush();//남아있는 데이터를 모두 출력시킴
		bw.close();//스트림을 닫음
	}
}

'알고리즘 > acmicpc.net' 카테고리의 다른 글

10871  (0) 2020.07.08
2439  (0) 2020.07.08
11021.  (0) 2020.07.08
2741. N찍 & 2742.N반대로찍  (0) 2020.07.08
15552. Fast A+B  (0) 2020.07.08
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int cnt = Integer.parseInt(br.readLine());
		int a,b;
		for (int i=1; i<=cnt ; i++){
			String line = br.readLine();
			StringTokenizer st = new StringTokenizer(line, " ");
			a=Integer.parseInt(st.nextToken());
			b=Integer.parseInt(st.nextToken());
			bw.write("Case #" + i + ": " + (a+b) +"\n");
		}

		bw.flush();//남아있는 데이터를 모두 출력시킴
		bw.close();//스트림을 닫음
	}
}

'알고리즘 > acmicpc.net' 카테고리의 다른 글

2439  (0) 2020.07.08
11022  (0) 2020.07.08
2741. N찍 & 2742.N반대로찍  (0) 2020.07.08
15552. Fast A+B  (0) 2020.07.08
8393. 하압  (0) 2020.07.07
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int cnt = Integer.parseInt(br.readLine());
		for (int i=1; i<=cnt ; i++){
			bw.write(i +"\n");
		}

		bw.flush();//남아있는 데이터를 모두 출력시킴
		bw.close();//스트림을 닫음
	}
}

 

1~CNT까지 찍기.

 

import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		int cnt = Integer.parseInt(br.readLine());
		for (int i=cnt; i>0 ; i--){
			bw.write(i +"\n");
		}

		bw.flush();//남아있는 데이터를 모두 출력시킴
		bw.close();//스트림을 닫음
	}
}

역순 출력

'알고리즘 > acmicpc.net' 카테고리의 다른 글

11022  (0) 2020.07.08
11021.  (0) 2020.07.08
15552. Fast A+B  (0) 2020.07.08
8393. 하압  (0) 2020.07.07
acmicpc.net => 백준의 알고리즘 사이트.  (0) 2020.07.07

+ Recent posts