예제 #1
0
static int obj_cond(int op, int obj, int arg)
{
  switch(op) {
    case 0:cret(in_scope(obj));  /* Present-- 
				      Do we want to use visible here?? */
    case 1:cret(is_within(obj,1000,1));  /* IsWearing */
    case 2:cret(is_within(obj,1,1)); 
        /* if (PURE_WEAR)  return (it_loc(obj)==1); else */
    case 3:cret(it_loc(obj)==0);  /* Nowhere */
    case 4:cret(it_loc(obj)!=0);
    case 5:cret(!player_has(obj) && in_scope(obj));
    case 6:cret(it_loc(obj)==arg);
    case 7:cret(it_on(obj));
    case 8:cret(!it_on(obj));
    case 9:cret(it_open(obj));
    case 10:cret(!it_open(obj));
    case 11:cretn(obj,locked);
    case 12:cret(!tnoun(obj) || !noun[obj-first_noun].locked);
    case 13:cretn(obj,edible);
    case 14:cretn(obj,drinkable);
    case 15:cretn(obj,poisonous);
    case 16:cretn(obj,movable);
    default:
      writeln("INTERNAL ERROR: Bad obj_cond value.");
      return 2;
  }
}
예제 #2
0
void
solve(char *test)
{
	int i, len = strlen(test);
	Words tmp;
	strcpy(tmp.word, test);
	if(bsearch(&tmp, sorted, total_words, sizeof(Words), cmp) != NULL) {
		printf("%s is correct\n", test);
		return;
	}
	printf("%s: ", test);
	for(i=0; i<total_words; i++) {
		if(words[i].len>len+1 || len>words[i].len+1)
			continue;
		if(words[i].len == len+1) {
			if(is_within(test, words[i].word))
				printf("%s ", words[i].word);
		} else if(words[i].len+1 == len) {
			if(is_within(words[i].word, test))
				printf("%s ", words[i].word);
		} else {
			if(is_replace(words[i].word, test))
				printf("%s ", words[i].word);
		}
	}
	printf("\n");
}
예제 #3
0
int main(void)
{
	const char string[] = {"The two forms are nearly equivalent. Keep in mind that the ?: is an expression and if-then-else is a statement. Note that neither the true nor false portions can be omitted from the conditional operator without an error report upon parsing. This contrasts with if-then-else statements, where the else clause can be omitted. Most of the languages emphasizing functional programming don't need such an operator as their regular conditional expression(s) is an expression in the first place e.g. the Scheme expression (if (> a b) a b) is equivalent in semantics to the C expression (a > b) ? a : b. This is also the case in many imperative "};
	char ch;

	for(ch = 'A'; ch <= 'z'; ch++)
	{
		printf("is %c in the string? ", ch);
		printf("%3s it appears %3d times\n", (is_within(ch, string)) ? "yes" : "no", is_within(ch, string));
	}

	return 0;
}
예제 #4
0
파일: exec5.c 프로젝트: courri/C
int main(void)
{
	char input[LEN];
	char ch;
	int found;
	printf("Enter a string: ");
	while (gets(input) && input[0] != '\0')
	{
		printf("Enter a character: ");
		ch = getchar();
		while (getchar() != '\n')
		{
			continue;
		}
		found = is_within(input, ch);
		if (found == 0)
		{
			printf("%c is not found in string. \n", ch);
		} 
		else
		{
			printf("%c found in string %s \n", ch, input);
		}
		printf("Next string: ");
	}
	puts("Done. \n");
	return 0;
}
예제 #5
0
파일: answer.c 프로젝트: hemiao3000/code
void main()
{
	char* s1 = "abcdefghhehelhellhello";
	char* s2 = "he";

	int ret = is_within(s1, s2);

	printf("%d\n", ret);
}