View Code of Problem 84

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

int main(){
	//盐的英文是salt,现在极缺,请找出输入中所有包含salt的行,不管大小写,是salt就要。
	char str[6][30] = {"Salt is necessary",
						"Water is not sAlt",
						"as salT as you can make it",
						"soy-bean sauce can be saLt",
						"soy-bean sauce only",
						"bean soy-bean sauce",
	};
	int i ,j;
	for(i=0;i<6;i++){
		j = 0;
		while(str[i][j+3]!='\0'){
			if((str[i][j] == 's'||str[i][j] == 'S')
			&&(str[i][j+1] == 'a'||str[i][j+1] == 'A')
			&&(str[i][j+2] == 'l'||str[i][j+2] == 'L')
			&&(str[i][j+3] == 't'|str[i][j+3] == 'T')){
				puts(str[i]);
				break;
			}
			j++;								
		}	
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 84