字符串子串

#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;
}

  

上一篇:R绘制扇形图


下一篇:学习python第七天