반응형

문제출처

https://www.acmicpc.net/problem/11718

 

문제풀이

그대로 입력받고 출력해주는 문제이다. cin을 사용하지 말고 getline을 사용하면 된다.

 

소스코드

C++

#include <iostream>
#include <string>
using namespace std;
int main() {
    string str;
    for(int i=0; i<100; i++) {
        getline(cin, str);
        cout<<str<<endl;
    }
    return 0;
}

 

C

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char name[101];
    name[0]='\0';
    while(fgets(name,100,stdin)){
        printf("%s",name);
        name[0]='\0';
    }
    return 0;
}

 

반응형

'Algorithm' 카테고리의 다른 글

[BOJ 1057] 토너먼트  (0) 2019.04.15
[BOJ 1094] 막대기  (0) 2019.04.15
[SWEA 1244] 최대 상금  (4) 2019.02.27
[BOJ 3908] 서로 다른 소수의 합  (0) 2019.02.27
[BOJ 2407] 조합  (0) 2019.02.26

+ Recent posts