生活随笔
收集整理的這篇文章主要介紹了
sdut 删数问题
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Problem Description
鍵盤輸入一個高精度的正整數(shù)n(≤100位),去掉其中任意s個數(shù)字后剩下的數(shù)字按照原來的左右次序組成一個新的正整數(shù)。編程對給定的n與s,尋找一種方案,使得剩下的數(shù)字組成的新數(shù)最小。
Input
輸入有多組 每組包括原始數(shù)n,要去掉的數(shù)字數(shù)s;
Output
輸出去掉s個數(shù)后最小的數(shù)
Example Input
178543 4
Example Output
13 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{ char s[150]; int n; while(~scanf("%s %d", s, &n)){ while(n > 0){ int len = strlen(s); int i =0; while(i < len && s[i] <= s[i+1]){ i++; } while(i < len){ s[i] = s[i+1]; i++; } n--; } int k; while(s[0] == '0'){ k = 0; int len = strlen(s); while(k < len){ s[k] = s[k+1]; k++; } } printf("%s\n", s); } return 0;
}
總結(jié)
以上是生活随笔為你收集整理的sdut 删数问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。