ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 백준 10709번: 기상캐스터
    출력(Print) 2018. 7. 23. 12:06
    반응형

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


    1. 문제

    문제 그대로 풀면 풀리는 문제 


    2. 알고리즘

    키워드 - 출력


    3. 코드


    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
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    #include <iostream>
    #include <sstream>
    #include <string>
    #include <algorithm>
    #include <functional>
    #include <vector>
    #include <list>
    #include <queue>
    #include <deque>
    #include <map>
    #include <set>
    #include <stack>
    #include <math.h>
     
    using namespace std;
     
    #define MAX_SIZE 100
    #define INF 0x7fffffff
    #define CENDL "\n"
    #define ll long long
     
    void solve(string s) {
        const int size = s.size();
        int prev = 0;
     
        for(int i=0; i<size; i++) {
            if (s[i] == 'c') {
                if (prev != 0) {
                    prev = 0;
                    cout << prev << " ";
                    prev++;
                } else {
                    cout << prev << " ";
                    prev++;
                }
            }
            else if(s[i] == '.') {
                if (prev == 0) {
                    cout << -<< " ";
                } else {
                    cout << prev << " ";
                    prev++;
                }
            }
        }
    }
     
    int main() {
     
        cin.tie(0);
        std::ios::sync_with_stdio(false);
     
        int n, m; cin >> n >> m;
     
        for(int i=0; i<n; i++) {
            string s; cin >> s;
            solve(s);
            cout << CENDL;
            s.clear();
        }
     
        return 0;
    }
     
    cs



    반응형

    '출력(Print)' 카테고리의 다른 글

    백준 2443번: 별찍기 - 6  (0) 2018.08.04
    백준 2442번: 별찍기 - 5  (0) 2018.08.04
    백준 2804번: 크로스워드 만들기  (0) 2018.07.29
    백준 15232번: Rectangles  (0) 2018.07.28
    백준 3076번: 상근이의 체스판  (0) 2018.07.05

    댓글

Designed by Tistory.