其他分享
首页 > 其他分享> > 字符串子串

字符串子串

作者:互联网

#include<stdio.h>
#include<string.h>

char james(char s[]) {
	int len = strlen(s),flag;
	char str[5];
	for (int i = 0; i < len; i++) {
		flag = 5;
		if (s[i] == 'J') {
			str[0] = s[i];
			flag--;
			if (s[i + 1] == 'a') {
				str[1] = s[i + 1];
				flag--;
			}
			if (s[i + 2] == 'm') {
				str[2] = s[i + 2];
				flag--;
			}
			if (s[i + 3] == 'e') {
				str[3] = s[i + 3];
				flag--;
			}
			if (s[i + 4] == 's') {
				str[4] = s[i + 4];
				flag--;
				break;
			}
		}
		else {
			continue;
		}
	}
	if (!flag){
		puts(s);
		}
		else {
			printf("no\n");
		}
	return 0;
}


int main()
{
	char names[][20] = { "Li.James","James","DJ","Park.z.James" };
	int i;
	for (i = 0; i < 4; i++)
		james(names[i]);
	return 0;
}

  

标签:子串,int,James,char,--,flag,str,字符串
来源: https://www.cnblogs.com/kmxojer/p/15058340.html