コード例 #1
0
ファイル: table.c プロジェクト: asccharania/learning
int main() {
 int x = enterNumber(32,127);
 int y = enterNumber(x, 127);

 printTable(x,y);

 return(EXIT_SUCCESS);
} 
コード例 #2
0
int main(){
	Border smallBorder, bigBorder, blankContent, topBorder, bottomBorder;
	
	setBorder(smallBorder, VERTICALDOUBLELINECHAR, HORIZONTALLINECHAR, CENTRECHAR, VERTICALDOUBLELINECHAR, VERTICALDOUBLELINECHAR);
	setBorder(bigBorder, LEFTMIDDLECHAR, HORIZONTALDOUBLELINECHAR, HORIZONTALDOUBLELINECHAR, DOUBLECENTRECHAR, RIGHTMIDDLECHAR);
	setBorder(blankContent, VERTICALDOUBLELINECHAR, BLANK, VERTICALLINECHAR, VERTICALDOUBLELINECHAR, VERTICALDOUBLELINECHAR);
	setBorder(topBorder, TOPLEFTCORNERCHAR, HORIZONTALDOUBLELINECHAR, HORIZONTALDOUBLELINECHAR, TOPMIDDLECHAR, TOPRIGHTCORNERCHAR);
	setBorder(bottomBorder, BOTTOMLEFTCORNERCHAR, HORIZONTALDOUBLELINECHAR, HORIZONTALDOUBLELINECHAR, BOTTOMMIDDLECHAR, BOTTOMRIGHTCORNERCHAR);
	
	DoubleIntArrPointer *possibleResult;
	possibleResult = new DoubleIntArrPointer[SIZE];
	int finalSolution [SIZE][SIZE];
	int possibleLength [SIZE][SIZE];
	
	setUpGiven(finalSolution);
	setUpPossible(possibleResult);
	setUpGivenPossibility(possibleResult, finalSolution, possibleLength);
	setUpChecks(possibleResult, finalSolution, possibleLength);
	
	while(!isSolved(possibleLength)){
		enterSequential(possibleResult, finalSolution, possibleLength);
		
		updateTrickColumn(possibleResult, finalSolution, possibleLength);
		updateTrickRow(possibleResult, finalSolution, possibleLength);
		
		for(int i = 1; i <= 9; i++){
			enterBox(possibleResult, finalSolution, possibleLength, i);
			enterNumber(possibleResult, finalSolution, possibleLength, i, ROWMODE);
			enterNumber(possibleResult, finalSolution, possibleLength, i, COLMODE);
			updateTrickRowAdvanced(possibleResult, finalSolution, possibleLength, i);
			updateTrickColAdvanced(possibleResult, finalSolution, possibleLength, i);
		}
	}
	
	for (int bigVerBox = 0; bigVerBox < VERBOX; bigVerBox++){
		for (int smallVerBox = 0; smallVerBox < VERBOX; smallVerBox++){
			if(smallVerBox == 0){				
				if (bigVerBox == 0){
					drawBorder(topBorder);
				}else{
					drawBorder(bigBorder);
				}
			}else{
				drawBorder(smallBorder);
			}
			
			for (int bigBox = 0; bigBox < HORBOX; bigBox++){
				for (int smallBox = 0; smallBox < HORBOX; smallBox++){
					if(smallBox == 0){
						if(bigBox != 0){
							printf("%c", blankContent.secondBorder);
						}else{
							printf("%c", blankContent.firstBorder);
						}
					}else{
						printf("%c", blankContent.innerBorder);
					}
					printf("%d", finalSolution[bigBox*3 + smallBox][bigVerBox*3 + smallVerBox]);
				}
			}
			printf("%c\n", blankContent.endBorder);
		}		
	}
	drawBorder(bottomBorder);
}