取最长递增子串的C程序!

#include<stdio.h>
#define N 100

int main()
{
	char str[N], *postion,*pos;
	int len=0,maxlen=0;
	printf("please enter a string:");
	scanf("%s",str);
	printf("%s\n",str);
	for (pos=str;*pos;pos++){
		if(*pos+1 != *(pos+1)){
			if(len>maxlen){
				maxlen=len;
				postion=pos-len;
				len=0;
			}
		}else{
			len++;
		}
	} 
	str[postion-str+maxlen+1] = (char)0;
	printf("%s",postion);
   
	return 0;
}

你可能感兴趣的:(取最长递增子串的C程序!)