VioletaBabel

10799번: 쇠막대기 본문

백준/백준-C++
10799번: 쇠막대기
Beabletoet 2017. 6. 11. 20:49

#include<cstdio>

int main()

{

char r[100001];

int rPlus = 0, total = 0;

scanf("%s", &r);

for (int i = 0; r[i] != '\0'; ++i)

{

if (r[i] == '(')

if (r[i + 1] == ')')

{

total += rPlus;

++i;

}

else

++rPlus;

else

{

++total;

--rPlus;

}

}

printf("%d", total);

}

'백준 > 백준-C++' 카테고리의 다른 글

10824번: 네 수  (0) 2017.06.11
11655번: ROT13  (0) 2017.06.11
10818번: 최소, 최대  (0) 2017.06.11
10814번: 나이순 정렬  (0) 2017.06.11
10825번: 국영수  (0) 2017.06.11
Comments