Given N-digit positive integer a, remove any K ≤ n digits, and the remaining digits are arranged in the original order to form a new positive integer.
For the given n-bit positive integers A and K, an algorithm is designed to find the smallest number of the remaining digits.Delete countSolution.
The principle of the algorithm should be that, starting from the highest bit, one-to-low-level search, once the number of the previous (high) Digit exceeds the current BIT, delete the previous digit until the number of K is deleted, if K entries are not deleted at the end, it indicates that the number is sorted from small to large, and the number of required digits is deleted from the maximum bit. My algorithms are as follows:
# Include <stdio. h>
Void main (){
Int I, J;
Int prefix;
Long N [18] = {1456385 ,}; //
Int Lenn = 18;
Int S = 12;
Int K = 0;
Prefix = N [0];
For (I = 0; I <s; I ++ ){
For (j = 1; j <Lenn-I; j ++ ){
If (N [J-1]> N [J]) {
K = J-1;
While (k <lenN-i-1 ){
N [k] = N [k + 1];
K ++;
}
N [lenN-i-1] = 0;
Break;
}
}
If (j = Lenn-I ){
K = I;
While (k <s ){
N [J-1] = 0;
J --;
K ++;
}
Break;
}
}
For (I = 0; I <Lenn-S; I ++)
Printf ("% d", N [I]);
Getchar ();
}
The running result is 333348.