티스토리 뷰
- 공백없애기
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
//freopen("input.txt", "rt", stdin);
char a[101], b[101];
int i, p=0;
gets(a); // scanf로는 공백을 포함한 문자를 모두 읽을 수 없음
for(i=0; a[i]!='\0'; i++){
if(a[i]!= ' '){
if(a[i]>=65 && a[i]<=90){
b[p++]=a[i]+32;
} else {
b[p++]=a[i];
}
}
}
b[p]='\0';
printf("%s\n", b);
return 0;
}
- 올바른 괄호
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
freopen("input.txt", "rt", stdin);
char a[101];
int i, cnt=0;
scanf("%s", &a);
for(i=0; a[i]!='\0'; i++){
if(a[i]=='(') cnt++;
else if(a[i]==')') cnt--;
if(cnt<0) break;
}
if(cnt==0) printf("YES\n");
else printf("NO\n");
return 0;
}
'algorithm' 카테고리의 다른 글
[c++] 자릿수의 합 (0) | 2020.11.29 |
---|---|
[c++] 모두의 약수 (0) | 2020.11.28 |
나이차이, 나이계산, 숫자만추출 (0) | 2020.11.26 |
자연수의 합, 진약수의 합 (0) | 2020.11.25 |
[Algorithm] 순환(recursion) 알고리즘(예제) (0) | 2020.05.30 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 재귀함수
- 알고리즘
- 교착상태
- Java
- 최단경로
- 동적프로그래밍
- client side rendering
- 구조체
- dfs
- BFS
- 세마포어
- 배열
- 퀵정렬
- 인접행렬
- javascript
- Stack
- 병행프로세스
- 입출력장치
- 클래스
- 이진탐색
- 운영체제
- stackframe
- C++
- 소프트웨어
- react
- 자료구조
- C
- 스텍
- 인접리스트
- server side rendering
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함