2013-04-26 3 views
0

스도쿠 퍼즐을 만들고 있습니다. 나는 이사회를 해왔다. 하지만 문제는이 상자에 숫자를 생성하는 방법에 대해 정말로 혼란 스럽습니다. 그것은 Char의 배열이기 때문입니다. 하지만 정수를 생성하고 싶습니다. 도움이 필요해.이 스도쿠 보드에서 숫자를 생성하는 방법 C++

이것은 내가 지금까지 가지고있는 것입니다.

enter code here 
#include <iostream> 
#include <string> 
#include <cstring> 

using namespace std; 


void main(){ 
//Descriptions and genral ideas 
cout << "WELCOME TO SUDOKU " << endl; 
cout << endl; 

cout << "RULES: "<< endl; 
cout << endl; 

cout << "->You'll be given a 9x9 board with some numbers depending on which level of difficulty you choose to play."<< endl; 
cout << endl; 

cout << "->You have to arrange numbers from 1 to 9 so that a number shows up once in one row, one column and in a 3x3 box." << endl; 
cout << endl; 

cout << "So, let's get started" << endl; 

cout << endl; 
cout <<endl; 



char dash[9][9]; 
for (int array=0; array<9; array++) { 
for (int array2=0; array2<9; array2++) { 
    dash[array][array2]='_'; 
} 
} 
char row[9]; 
char column[9]; 
char num[81]; 

int length; 
length=strlen(row); 
//Replaces the _'s in the specified rows/columns and replaces them with the integer the user specified. 
for (int i=0; i<length; i++) { 
dash[row[i]][column[i]]=num[i]; 
} 

//Builds the Sudoko board and outputs the full 9x9 array. 

cout << "-------------------------------------" << endl; 
for (int count=0; count<3; count++) { 
for (int count2=0; count2<3; count2++) { 
    cout << "|_" << dash[count][count2*3] << "_|_" << dash[count][count2*3+1] << "_|_" << dash[count][count2*3+2] << "_"; 
} 
    cout << "|" << endl; 
} 
cout << "-------------------------------------" << endl; 
for (int count=3; count<6; count++) { 
for (int count2=0; count2<3; count2++) { 
    cout << "|_" << dash[count][count2*3] << "_|_" << dash[count][count2*3+1] << "_|_" << dash[count][count2*3+2] << "_"; 
} 
cout << "|" << endl; 
} 
cout <<"-------------------------------------" << endl; 
for (int count=6; count<9; count++) { 
for (int count2=0; count2<3; count2++) { 
    cout << "|_" << dash[count][count2*3] << "_|_" << dash[count][count2*3+1] << "_|_" << dash[count][count2*3+2] << "_"; 
} 
cout << "|" << endl; 
} 
cout << "-------------------------------------" << endl; 




system("pause"); 
} 

답변

0

당신은 단순히 추가하는 임의의 기능 수를 생성하고 "문자"로 번역 할 수 있습니다 (48)