Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	table := [9][9]int{}
	check := [9][9]bool{}
	n, _ := strconv.Atoi(scanner.Text())
	for n > 0 {
		n--
		for i := 0; i < 9; i++ {
			for j := 0; j < 9; j++ {
				table[i][j] = nextInt()
			}
		}
		for i := 0; i < 9; i++ {
			for j := 0; j < 9; j++ {
				ok := true
				for k := 0; k < 9; k++ {
					if table[i][j] == table[i][k] && j != k {
						ok = false
					}
				}
				for k := 0; k < 9; k++ {
					if table[i][j] == table[k][j] && i != k {
						ok = false
					}
				}
				seci := i / 3
				secj := j / 3
				for k := 0; k < 3; k++ {
					for l := 0; l > 3; l++ {
						if table[seci*3+k][secj*3+l] == table[i][j] && seci*3+k != i && secj*3+l != j {
							ok = false
						}
					}
				}
				if !ok {
					check[i][j] = true
				}
			}
		}
		for i := 0; i < 9; i++ {
			for j := 0; j < 9; j++ {
				if check[i][j] {
					fmt.Print("*")
				} else {
					fmt.Print(" ")
				}
				fmt.Print(table[i][j])
			}
			fmt.Println()
		}
		if n != 0 {
			fmt.Println()
		}
	}
}

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int field[10][10], used[10];
	bool judge[10][10];

	int num;
	cin >> num;
	while(num--)
	{
		memset(judge, false, sizeof(judge));

		for(int i = 0; i < 9; i++)
		{
			for(int j = 0; j< 9; j++)
			{
				cin >> field[i][j];
			}
		}
		for(int i = 0; i < 9; i++)
		{
			memset(used, 0, sizeof(used));
			for(int j = 0; j < 9; j++)
			{
				used[field[i][j]]++;
			}
			for(int j = 1; j <=9; j++)
			{
				if(used[j] >= 2)
				{
					for(int k = 0; k < 9; k++)
					{
						if(field[i][k] == j)
						{
							judge[i][k] = true;
						}
					}
				}
			}
			memset(used, 0, sizeof(used));
			for(int j = 0; j < 9; j++)
			{
				used[field[j][i]]++;
			}
			for(int j = 1; j<= 9; j++)
			{
				//printf("%d%s",used[j] ,(j == 9)?"\n":" ");
				if(used[j] >= 2)
				{
					for(int k = 0; k < 9; k++)
					{
						if(field[k][i] == j)
						{
							judge[k][i] = true;
						}
					}
				}
			}
		}

		for(int l = 3; l < 9; l+=3)
		{
			for(int m = 3; m < 9; m+=3)
			{
				memset(used, false, sizeof(used));
				for(int i = 0; i < 3; i++)
				{
					for(int j = 0; j < 3; j++)
					{
						used[field[i+l][j+m]]++;
					}
				}

				for(int n = 1; n <=9; n++)
				{
					if(used[n] >= 2)
					{
						for(int i = 0; i < 3; i++)
						{
							for(int j = 0; j < 3; j++)
							{
								if(field[i+l][j+m] == n)
								{
									judge[i+l][j+m] = true;
								}
							}
						}
					}
				}
			}
		}

		for(int i = 0; i < 9; i++)
		{
			for(int j = 0; j < 9; j++)
			{
				printf("%s%d",(judge[i][j])?"*":" " ,field[i][j]);
			}
			puts("");
		}
		if(num != 0)
		{
			puts("");
		}
	}
}

C++: #include <iostream>
#include <cstdio>

using namespace std;

int puzzle[10][10];
int col[10][10], row[10][10]; // 列，行
bool check[10][10];  // 間違っている場合はfalse
int n;

/*
  rect[0] rect[1] rect[2]
  rect[3] rect[4] rect[5]
  rect[6] rect[7] rect[8]
*/
int rect[10][10];

void solve()
{
    // 行・列のチェック
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            // 列のチェック
            if (col[j][puzzle[i][j] - 1] != -1) {
                int bf = col[j][puzzle[i][j] - 1];
                check[bf][j] = check[i][j] = false;
                col[j][puzzle[i][j] - 1] = i;
            }
            else
                col[j][puzzle[i][j] - 1] = i;

            // 行のチェック
            if (row[i][puzzle[i][j] - 1] != -1) {
                int bf = row[i][puzzle[i][j] - 1];
                check[i][bf] = check[i][j] = false;
                row[i][puzzle[i][j] - 1] = j;
            }
            else
                row[i][puzzle[i][j] - 1] = j;
        }
    }

    // 3x3の領域のチェック
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                int x = (i % 3) * 3 + k;
                int y = (i / 3) * 3 + j;

                if (rect[i][puzzle[y][x] - 1] != -1) {
                    int nx = (i % 3) * 3 + (rect[i][puzzle[y][x] - 1] % 3);
                    int ny = (i / 3) * 3 + (rect[i][puzzle[y][x] - 1] / 3);

                    check[ny][nx] = check[y][x] = false;
                    rect[i][puzzle[y][x] - 1] = j * 3 + k;
                }
                else
                    rect[i][puzzle[y][x] - 1] = j * 3 + k;                    
            }
        }
    }

    for (int i = 0; i < 9; i++)
        for (int j = 0; j < 9; j++) {
            if (check[i][j]) 
                printf(" %d", puzzle[i][j]);
            else
                printf("*%d", puzzle[i][j]);
            
            if (j + 1 == 9)
                putchar('\n');
        }
    putchar('\n');
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 9; j++)
            for (int k = 0; k < 9; k++) {
                cin >> puzzle[j][k];
                col[j][k] = row[j][k] = rect[j][k] = -1;
                check[j][k] = true;
            }
        solve();
    }
        

    return 0;
}

C++: #include <cstdio>
using namespace std;

int main(){
    int N;
    for(scanf("%d", &N); N--;){
        char pz[9][12] = {};
        char res[9][12] = {};
        for(int i = 0; i < 9; i++){
            for(int j = 0; j < 9; j++){
                scanf(" %c", &pz[i][j]);
            }
        }
        for(int i = 0; i < 9; i++){
            for(int j = 0; j < 9; j++){
                bool flg = true;
                for(int k = 0; k < 9; k++){
                    if(i == k) continue;
                    if(pz[i][j] == pz[k][j]) flg = 0;
                }
                for(int k = 0; k < 9; k++){
                    if(j == k) continue;
                    if(pz[i][j] == pz[i][k]) flg = 0;
                }
                if(flg){
                    res[i][j] = ' ';
                }else{
                    res[i][j] = '*';
                }
            }
        }
        for(int i = 0; i < 9; i++){
            for(int j = 0; j < 9; j++){
                printf("%c", res[i][j]);
                printf("%c", pz[i][j]);
            }
            puts("");
        }
        if(N>=2) puts("");
    }
    return 0;
}