面试遇到的题目,拿出来分享。
#include
void main()
{
char input[100];
char
output[100] = {0};
int count = 0, maxlen = 0, i = 0;
char *in=input,
*out=output,*temp=NULL,*final=NULL;
printf("Please input string(length under
100):\n");
scanf("%s", input);
printf("Input string is %s\n",
input);
while(*in!='\0')
{
if(*in>='0'&&*in<='9')
{
count=0;
temp=in;
for(;(*in>='0')&&(*in<='9');in++)
count++;
if (maxlen
{
maxlen=count;
final=temp;
}
}
in++;
} // while
fo r(i=0; i
*(out++) = *(final++);
*out='\0';
printf("Maxlen is %d\n", maxlen);
printf("Output is %s\n",
output);
}
阅读(850) | 评论(0) | 转发(0) |