Recently I coded a program to choose k numbers from the string in order from left to right to print out the number that has k characters and the smallest that can be made from the string itself for example : Input : 3 89678982 Output: 672 Then my code didn't print at all!! Code :
#include<bits/stdc++.h>
using namespace std;
int k,j=0,i;
string s;
int main() {
    cin>>k>>s;
    for(int i=0;i<s.size();i++) s[i]-=48;
    int the2=0;
    int Min=s[0];
    while(j<0) {
    for(i=the2;i<s.size();i++) {
            if(Min>s[i]) 
            {
                Min=s[i];
                break;
            }
        }
        the2=i;
        Min=s[i+1];
        cout<<Min;
        j++;
    }
}
Why did this happen and how do I fix it?
 
     
    