ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 백준 2804번: 크로스워드 만들기
    출력(Print) 2018. 7. 29. 15:41
    반응형

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


    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
    #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>
    #include <memory.h>
     
    using namespace std;
     
    #define MAX_SIZE 100
    #define INF 0x7fffffff
    #define CENDL "\n"
    #define ll long long
     
    int main() {
     
        cin.tie(0);
        std::ios::sync_with_stdio(false);
     
        string s1, s2; cin >> s1 >> s2;
     
        int row = 0;
        int col = 0;
        for (int i=0; i<s1.size(); i++) {
            bool isOk = false;
            for (int j=0; j<s2.size(); j++) {
                if (s1[i] == s2[j]) {
                    row = i;
                    col = j;
                    isOk = true;
                    break;
                }
            }
     
            if (isOk) {
                break;
            }
        }
     
        for (int i = 0; i < s2.size(); i++) {
            for (int j = 0; j < s1.size(); j++) {
                if (j == row && i!=col) { 
                    cout << s2[i]; 
                } else if (i == col) { 
                    cout << s1[j]; 
                } else { 
                    cout << '.'
                }
            } 
            cout << CENDL;
        }
     
        return 0;
    }
    cs

    반응형

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

    백준 2443번: 별찍기 - 6  (0) 2018.08.04
    백준 2442번: 별찍기 - 5  (0) 2018.08.04
    백준 15232번: Rectangles  (0) 2018.07.28
    백준 10709번: 기상캐스터  (0) 2018.07.23
    백준 3076번: 상근이의 체스판  (0) 2018.07.05

    댓글

Designed by Tistory.