SHARE
TWEET

Untitled

a guest Sep 18th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <string>
  2. #include <vector>
  3. #include<iostream>
  4. using namespace std;
  5.  
  6. string solution(string number, int k) {
  7.     string answer = "";
  8.     int n=number.size();
  9.     int a=-1, mm=-1, nj;
  10.     int nn=n-k;     //nn : return값의 길이
  11.     for(int i=0;i<nn;i++){
  12.         for(int j=a+1;j<n-(nn-i)+1;j++){
  13.             if(mm<number[j]-'0') {  //string의 원소 문자를 int형으로 변환.
  14.                 mm=number[j]-'0';   //atoi는 string을 통으로 int로 변환할때.
  15.                 nj=j;
  16.             }
  17.         }
  18.         answer.append(to_string(mm));  
  19.         a=nj;
  20.         mm=-1;  //mm초기화
  21.     }
  22.     return answer;
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top