Beispiel #1
0
Node_t * quiz (Node_t * tree)
{
    const char yes[] = "да";
    const char  no[] = "нет";

    printf ("Это %s?\n", tree->data);
    char * answer = (char *) calloc (MAX_DATA_SIZE, sizeof (char));
    scanf ("%s", answer);
    while ( strcmp (answer, yes) && strcmp (answer, no))
    {
        printf ("это не ответ! Введите %s или %s\n", yes, no);
        scanf  ("%s", answer);
    }

    if ( ! strcmp (answer, yes))
    {
        if (tree->left)
            quiz (tree->left);
        else
        {
            printf ("Я так и знал!\n");
        }
    }
    else
    {
        if (tree->right)
            quiz (tree->right);
        else
        {
            printf ("Я не знаю, что это. Добавить ответ?\n");
            scanf ("%s", answer);
            while ( strcmp (answer, yes) && strcmp (answer, no))
            {
                printf ("это не ответ! Введите %s или %s\n", yes, no);
                scanf  ("%s", answer);
            }
            if ( ! strcmp (answer, yes))
            {
                printf ("Введите определение\n");
                scanf  ("%s", answer);
                tree->right = newNode (answer, NULL, NULL);
            }
        }
    }

    return tree;
}
Beispiel #2
0
void QuizVariant::regenerate()
{
	for(int i=0; i<this->_data.count(); ++i)
		delete _data[i];
	_data.clear();
	_questions = quiz()->structure()->questions();
	for(int i=0; i<_questions.count(); ++i)
		_data.append(Generator::instance()->get(_questions.at(i)));
}
Beispiel #3
0
int
main(int argc, char *argv[])
{
	int ch;
	const char *indexfile;

	/* Revoke setgid privileges */
	setgid(getgid());

	indexfile = _PATH_QUIZIDX;
	while ((ch = getopt(argc, argv, "i:t")) != -1)
		switch(ch) {
		case 'i':
			indexfile = optarg;
			break;
		case 't':
			tflag = 1;
			break;
		case '?':
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	switch(argc) {
	case 0:
		get_file(indexfile);
		show_index();
		break;
	case 2:
		get_file(indexfile);
		get_cats(argv[0], argv[1]);
		quiz();
		break;
	default:
		usage();
	}
	exit(0);
}