์ƒ์„ธ ์ปจํ…์ธ 

๋ณธ๋ฌธ ์ œ๋ชฉ

[๋ฐฑ์ค€(BOJ)] 11656๋ฒˆ: ์ ‘๋ฏธ์‚ฌ ๋ฐฐ์—ด (C++)

PROGRAMMING/Algorithm

by koharin 2021. 8. 30. 18:12

๋ณธ๋ฌธ

728x90
๋ฐ˜์‘ํ˜•

๐Ÿ’ก ๋ฌธ์ œํ’€์ด ๊ณผ์ •


sort ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ compare ํ•จ์ˆ˜๋ฅผ ์‚ฌ์ „ ์ •๋ ฌ์ด ๋˜๋„๋ก ๊ตฌํ˜„ํ•ด์คฌ๋‹ค.

 

 

๐Ÿ’ป ์ฝ”๋“œ


#include <bits/stdc++.h>
using namespace std;

bool compare(string x, string y){
    return x < y;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string S; cin >> S;
    vector<string> v;
    for(int i=0; i<S.size(); i++){
        v.push_back(S.substr(i));
    }
    sort(v.begin(), v.end(), compare);
    for(string s: v) cout << s << '\n';
}

 

 

๐Ÿ“„ ์ œ์ถœ๊ฒฐ๊ณผ


728x90
๋ฐ˜์‘ํ˜•

๊ด€๋ จ๊ธ€ ๋”๋ณด๊ธฐ