일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- 앞산카페
- 큐
- 수성못삼겹살
- 들안길삼겹살
- 수성못맛집
- 대구맛집
- 서울맛집
- BFS
- 반복문
- 수성구맛집
- 압구정데이트
- 안지랑카페
- 대구카페
- C#
- programmers
- 수성구데이트
- 대명동맛집
- 대구고깃집
- 별찍기
- 정렬
- oracle
- 브루트 포스
- 오라클
- 대구삼겹살
- 백준
- 대구데이트
- 조건문
- 범어동맛집
- 프로그래머스
- SQL
- Today
- Total
모든 일상
C# 백준 9012번 문제 괄호 본문
using System;
using System.Collections;
using System.Collections.Generic;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
int cnt = int.Parse(Console.ReadLine());
string[] result = new string[cnt];
Stack stack_1 = new Stack(cnt);
bool error = false;
for (int i = 0; i < cnt; i++)
{
string s = Console.ReadLine();
stack_1.Clear();
for(int j = 0; j<s.Length; j++)
{
if (s.Substring(j,1) == "(")
{
stack_1.Push(s.Substring(j, 1));
}
else if (s.Substring(j, 1) == ")")
{
if (stack_1.Count != 0)
{
stack_1.Pop();
result[i] = "YES";
}
else
{
result[i] = "NO";
break;
}
}
}
if (stack_1.Count != 0)
{
result[i] = "NO";
}
}
for(int i = 0; i<cnt; i++)
{
Console.WriteLine(result[i]);
}
}
}
}
'코딩 공부 > C#' 카테고리의 다른 글
C# 백준 7562번 문제 나이트의 이동 (0) | 2022.08.05 |
---|---|
C# 백준 1696번 문제 숨바꼭질 (0) | 2022.08.05 |
C# 백준 10828번 문제 스택 (0) | 2022.07.27 |
C# 백준 7568번 문제 덩치 (0) | 2022.07.27 |
C# 백준 2941번 문제 크로아티아 알파벳 (0) | 2022.07.26 |