Exemple #1
0
int main(void) {
    int i;

    // 打印顶部横线部分
    printLine();

    // 打印左上角
    for (i= 1; i < WIDTH; ++i) {
        printBlank(OFFSET + (WIDTH - i));
        putchar(CHAR);
        putchar('\n');
    }

    // 打印竖线部分
    for (i = 0; i < WIDTH; ++i) {
        printBlank(OFFSET);
        putchar(CHAR);
        putchar('\n');
    }

    // 打印左下角
    for (i= 1; i < WIDTH; ++i) {
        printBlank(OFFSET + i);
        putchar(CHAR);
        putchar('\n');
    }

    // 打印底部横线
    printLine();

    return 0;
}
Exemple #2
0
void Map::generate()
{
	switch (choice)
	{
		case 1: printBlank();
			break;
		case 2: printBlank(true);
			break;
		case 3: printWalled();
			break;
		case 4: printWalled(true);
			break;
	}
}
Exemple #3
0
/* 文字列textから文字列patternを検索する(KMP法) */
int kmp_search(uchar text[], uchar pattern[])
{
	int i = 0  /* 注目しているテキストの位置 */
	  , j = 0  /* 注目しているパターンの位置 */
	;
	int text_len
	  , patn_len
	;
	text_len = strlen((char*)text);    /* テキストの長さをセット */
	patn_len = strlen((char*)pattern); /* パターンの長さをセット */
	/* テキストの最後尾に行き当たるか、パターンが見つかるまで繰り返す */
	while ( i < text_len && j < patn_len ) {
		if ( text[i] == pattern[j] ) {
			printf("%c", pattern[j]);
			i++;
			j++;
		} else {
			printf("%c ...failure\n", pattern[j]);
			j -= next[j];
			if ( j < 0 ) {
				i++;
				j++;
			}
			printBlank(i);
		}
	}
	
	if ( j == patn_len ) {
		printf(" ...success\n");
		return i - patn_len;
	}

	return -1;
}
Exemple #4
0
/* 文字列textから文字列patternを検索する(力まかせ法) */
int brute_force_search(uchar text[], uchar pattern[])
{
	int i = 0  /* 注目しているテキストの位置 */
	  , j = 0  /* 注目しているパターンの位置 */
	;
	int text_len
	  , patn_len
	;
	text_len = strlen((char*)text);    /* テキストの長さをセット */
	patn_len = strlen((char*)pattern); /* パターンの長さをセット */
	while ( i < text_len && j < patn_len ) {
		if ( text[i] == pattern[j] ) {
			printf("%c", pattern[j]);
			i++;
			j++;
		} else {
			printf("%c ...failure\n", pattern[j]);
			i = i - j+1;
			j = 0;
			printBlank(i);
		}
	}
	if ( j == patn_len ) {
		printf(" ...success\n");
		return i - patn_len;
	}
	else
		return -1;
}
Exemple #5
0
/* 文字列textから文字列patternを検索する(BM法) */
int bm_search(uchar text[], uchar pattern[]) {
	int i; /* 注目しているテキストの位置 */
	int j; /* 注目しているパターンの位置 */
	int text_len, patn_len;

	text_len = strlen((char*)text);    /* テキストの長さをセット */
	patn_len = strlen((char*)pattern); /* パターンの長さをセット */

	i = patn_len - 1;

	while( i < text_len ) {
		j = patn_len - 1;
		printArrows(i);
		printf("%c", pattern[j]);
		while( text[i] == pattern[j] ) {
			if ( j == 0 ) {
				printf("  ...success\n");
				return i;
			}
			i--;
			j--;
			printf("\n");
			printBlank(i);
			printf("%c", pattern[j]);
		}
		printf("  ...failure\n");
		i += skip[ text[i] ] > patn_len-j ? skip[ text[i] ] : patn_len-j;
	}
	return -1;
}
Exemple #6
0
int procs(char *str)
{
	int len = strlen(str);
	int i = 0, j = 0;
	int times = len/3 + ((len%3==0)?0:1);
	
	for( i = 0; i < times; i++ )
	{
		if( i != times - 1 )
		{
			printf("%c", str[i]);
			if( len % 3 == 0 )
			{
                printBlank( len / 3 );
            }
			else
			{
				printBlank(len % 3 + len / 3 - 2);
			}

			printf("%c\n", str[len - 1 - i]);
		}
		else
		{
            if( len % 3 == 0 )
            {
    			for( j = 0; j < (len % 3 + len / 3 + 2); j++ )
    			{
    				printf("%c", str[j+times - 1]);
    			}                
            }
            else
            {
    			for( j = 0; j < (len % 3 + len / 3); j++ )
    			{
    				printf("%c", str[j+times - 1]);
    			}
            }
			printf("\n");
		}
	}
	
	return 0;
}
OsagoMaster::OsagoMaster(QObject *parent) :
    QObject(parent)
{
    dialogs.push_back(new osagoCalcForm(&data));
    dialogs.push_back(new OsagoBlankDataForm(&data.insurancer,Driver::Insurancer, &data.insurancerIsOwner));
    dialogs.push_back(new OsagoBlankDataForm(&data.owner,Driver::Owner, &data.insurancerIsOwner));
    dialogs.push_back(new OsagoTsBlank(&data.transport, &data.insurancerIsOwner));
    dialogs.push_back(new OsagoUsingInfoForm(&data));
    connect(qobject_cast<osagoCalcForm*>(dialogs.at(0)), SIGNAL(next()), this, SLOT(next()));
    connect(qobject_cast<OsagoBlankDataForm*>(dialogs.at(1)), SIGNAL(prev()), this, SLOT(prev()));
    connect(qobject_cast<OsagoBlankDataForm*>(dialogs.at(1)), SIGNAL(next(int)), this, SLOT(next(int)));
    connect(qobject_cast<OsagoBlankDataForm*>(dialogs.at(2)), SIGNAL(prev()), this, SLOT(prev()));
    connect(qobject_cast<OsagoBlankDataForm*>(dialogs.at(2)), SIGNAL(next(int)), this, SLOT(next(int)));
    connect(qobject_cast<OsagoTsBlank*>(dialogs.at(3)), SIGNAL(prev(int)), this, SLOT(prev(int)));
    connect(qobject_cast<OsagoTsBlank*>(dialogs.at(3)), SIGNAL(next()), this, SLOT(next()));
    connect(qobject_cast<OsagoUsingInfoForm*>(dialogs.at(4)), SIGNAL(prev()), this, SLOT(prev()));
    connect(qobject_cast<OsagoUsingInfoForm*>(dialogs.at(4)), SIGNAL(printRequest()), this, SLOT(printRequest()));
    connect(qobject_cast<OsagoUsingInfoForm*>(dialogs.at(4)), SIGNAL(printBlank()), this, SLOT(printBlank()));
    dialogs.at(0)->show();
    foreach (QDialog* dial, dialogs) {
        dial->setModal(true);
    }
Exemple #8
0
void printLine() {
    printBlank(OFFSET + WIDTH);
    printChar(CHAR, WIDTH+2);
    putchar('\n');
}