반응형
[ 11382번 ]
https://www.acmicpc.net/problem/11382
[ C# ]
string[] s = Console.ReadLine().Split();
long[] nums = new long[3];
long total = 0;
for(int i = 0; i < 3; i++){
nums[i] = long.Parse(s[i]);
total += nums[i];
}
Console.Write(total);
[ Python ]
s = list(map(int, input().split()))
total = 0
for i in range(3): # for 루프 문법 수정
total += s[i]
print(total)
[ 10171번 ]
https://www.acmicpc.net/problem/10171
[ C# ]
Console.WriteLine("\\ /\\\n ) ( ')\n( / )\n \\(__)|");
[ Python ]
print("\\ /\\\n ) ( ')\n( / )\n \\(__)|")
\(백슬래시)를 출력하려면 \\로 입력해야 한다.
한 줄 띄기 위해서 \n을 중간에 넣는다.
쉬어가는 문제..! 귀여운 고양이 ~
[ 10172번 ]
https://www.acmicpc.net/problem/10172
[ C# ]
Console.WriteLine(@"|\_/|");
Console.WriteLine(@"|q p| /}");
Console.WriteLine("( 0 )\"\"\"\\");
Console.WriteLine("|\"^\"` |");
Console.WriteLine(@"||_/=\\__|");
C#에서
\(백슬래시)를 이스케이프 문자로 처리하지 않기 위해서 큰 따옴표 앞에 @를 붙여주면 된다!
"(큰따옴표)를 출력하기 위해서는 "(큰따옴표) 앞에 \(역슬래시)를 붙여주면 된다.
[ Python ]
print('''|\_/|
|q p| /}
( 0 )"""\\
|"^"` |
||_/=\\\\__|''')
파이썬은 여러 줄의 문자열을 출력하려면 '(작은 따옴표) 또는 "(큰 따옴표)를 3개 연속으로 사용해 문자열을 감싸면 된다.
그리고 \(백슬래시)를 출력하기 위해서는 \\ 백슬래시를 연속으로 두 개 사용 하면된다.
이것도 쉬어가는 문제 귀여운 강아지~
반응형
'코딩 공부 > 백준 코딩테스트' 카테고리의 다른 글
[백준 코딩테스트] 2753번, 14681번 | C, C#, Python (0) | 2023.04.05 |
---|---|
[백준 코딩테스트] 1330번, 9498번 | C, C#, Python (0) | 2023.04.05 |
[백준 코딩테스트] 10430번, 2588번 | C#, Python (0) | 2023.04.04 |
[백준 코딩테스트] 10926번, 18108번 | C#, Python (0) | 2023.04.04 |
[백준 코딩테스트] 1008번, 10869번 | C#, Python (0) | 2023.04.04 |