๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm/๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜

[๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜] 11654๋ฒˆ - ์•„์Šคํ‚ค ์ฝ”๋“œ

by ์ฝ”๋”ฉํ•˜๋Š” ๋ถ•์–ด 2021. 2. 2.
๋ฐ˜์‘ํ˜•

8. ๋ฌธ์ž์—ด - ์•„์Šคํ‚ค ์ฝ”๋“œ

 

 

๋ฌธ์ œ) ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž, ๋Œ€๋ฌธ์ž, ์ˆซ์ž 0-9์ค‘ ํ•˜๋‚˜๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ์ฃผ์–ด์ง„ ๊ธ€์ž์˜ ์•„์Šคํ‚ค ์ฝ”๋“œ๊ฐ’์„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

์ž…๋ ฅ ์ถœ๋ ฅ
A 65

 

์ž…๋ ฅ ์ถœ๋ ฅ
C 67

 

์ž…๋ ฅ ์ถœ๋ ฅ
0 48

 

์ž…๋ ฅ ์ถœ๋ ฅ
9 57

 

์ž…๋ ฅ ์ถœ๋ ฅ
a 97

 

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();

		int result = n.charAt(0); // ๋ฌธ์ž์—ด์„ char๋กœ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์„œ๋“œ
		System.out.print(result);

	}
}

for๋ฌธ์œผ๋กœ ํ•˜๋‹ค๊ฐ€ ์ข‹์€ ๋ฉ”์„œ๋“œ๋ฅผ ๋ฐœ๊ฒฌ!

์—ญ์‹œ ์‚ฌ๋žŒ์€ ๋ฐฐ์›Œ์•ผํ•ด

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€