简单说下就是我现在有组数独Sudoku[9][9]={{........}}和这组数独的实际答案answer[9][9]={{....}}
我现在要检验我Sudoku正确性(忽略未填写的部分0)(红色部分就是错误部分哈),所以就做了个程序:
#include <stdio.h>
int main()
{
int c;
int d;
int Sudoku[9][9]={{2,1,4,3,5,0,0,0,3},
{6,0,0,0,0,9,4,2,0},
{8,0,0,1,0,0,0,9,0},
{0,0,5,0,9,0,0,4,0},
{4,0,0,7,0,8,0,5,2},
{0,7,0,0,2,0,6,0,0},
{0,9,0,0,0,1,0,0,5},
{0,2,8,3,0,0,0,0,4},
{5,0,0,0,6,0,7,1,0}};
int answer[9][9]={
{9,1,4,2,5,6,8,7,3},
{6,5,7,8,3,9,4,2,1},
{8,3,2,1,4,7,5,9,6},
{2,8,5,6,9,3,1,4,7},
{4,6,9,7,1,8,3,5,2},
{3,7,1,5,2,4,6,8,9},
{7,9,6,4,8,1,2,3,5},
{1,2,8,3,7,5,9,6,4},
{5,4,3,9,6,2,7,1,8}};
for(c=0; c<9; c++)
{
for(d=0; d<9; d++)
{
if (Sudoku[c][d] != 0 && Sudoku[c][d] != answer[c][d])
{
printf("wrong");
}
}
}
}
但我其实想要的不是它发出wrong,而是像上面那样把错误的地方加粗或者变颜色该怎么做?(我可以根据c和d算出 出错数字在debug中的位置(x,y)
求各位简要说说方法。如要看详情我能贴出全程序。。。。谢谢各位了
------解决方案--------------------------------------------------------
建议这样:
正确的用 1 2 3 4 5 6 7 8 9
错误的用 ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨
比加粗、高亮简单,感觉也实用。
------解决方案--------------------------------------------------------
#include <Windows.h>
using namespace std;
int main()
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED );
printf("this is a test Application");
return 0;
}