要求:求最大递增数
如:1231123451
输出12345
#include<stdio.h> #include<assert.h> void find(char *s) { int maxleng = 0; int length = 1; int pos = 0; int i = 0; while(s[i] !=' ') { if((s[i])<'0'||(s[i]>'9')) { assert(0); } if((s[i+1]-'0') > (s[i] -'0')) { length++; i++; continue; } if(length > maxleng) { maxleng = length; pos = i -maxleng; pos++; length = 1; i++; continue; } i++; length = 1; } for(int j =0; j < maxleng; j++) { printf("%c",s[pos++]); } } int main( ) { char s[100]; scanf("%s",s); find(s); return 0; }