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 {
		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()
		}
		n--
	}
}

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

C++: #include <iostream>
#define BOARD_SIZE 9
#define CELL_SIZE 3

void init1(int a[BOARD_SIZE])
{
	for (int i=0; i<BOARD_SIZE; i++) a[i] = 0;
}

void init2(bool a[BOARD_SIZE][BOARD_SIZE])
{
	for (int i=0; i<BOARD_SIZE; i++) {
		for (int j=0; j<BOARD_SIZE; j++) a[i][j] = false;
	}
}

void check_vertical(int board[BOARD_SIZE][BOARD_SIZE], bool v[BOARD_SIZE][BOARD_SIZE])
{
	int appeared[BOARD_SIZE];
	
	for (int j=0; j<BOARD_SIZE; j++) {
		init1(appeared);
		for (int i=0; i<BOARD_SIZE; i++) appeared[board[i][j]-1]++;
		for (int i=0; i<BOARD_SIZE; i++) {
			if (appeared[board[i][j]-1] > 1) v[i][j] = true;
		}
	}
}

void check_horizontal(int board[BOARD_SIZE][BOARD_SIZE], bool v[BOARD_SIZE][BOARD_SIZE])
{
	int appeared[BOARD_SIZE];
	
	for (int i=0; i<BOARD_SIZE; i++) {
		init1(appeared);
		for (int j=0; j<BOARD_SIZE; j++) appeared[board[i][j]-1]++;
		for (int j=0; j<BOARD_SIZE; j++) {
			if (appeared[board[i][j]-1] > 1) v[i][j] = true;
		}
	}
}

void check_cell(int board[BOARD_SIZE][BOARD_SIZE], bool v[BOARD_SIZE][BOARD_SIZE])
{
	int appeared[BOARD_SIZE];
	
	for (int c=0; c<BOARD_SIZE; c++) {
		init1(appeared);
		int offseti = (c/CELL_SIZE) * CELL_SIZE;
		int offsetj = (c%CELL_SIZE) * CELL_SIZE;
		for (int i=0; i<CELL_SIZE; i++) {
			for (int j=0; j<CELL_SIZE; j++) appeared[board[offseti + i][offsetj + j]-1]++;
		}
		for (int i=0; i<CELL_SIZE; i++) {
			for (int j=0; j<CELL_SIZE; j++) {
				if (appeared[board[offseti + i][offsetj + j]-1] > 1) v[offseti + i][offsetj + j] = true;
			}
		}
	}
}

int main()
{
	int board[BOARD_SIZE][BOARD_SIZE];
	bool violates[BOARD_SIZE][BOARD_SIZE];
	int n;
	std::cin >> n;
	for (int k=0; k<n; k++) {
		
		for (int i=0; i<BOARD_SIZE; i++) {
			for (int j=0; j<BOARD_SIZE; j++) std::cin >> board[i][j];
		}
		init2(violates);
		
		check_vertical(board, violates);
		check_horizontal(board, violates);
		check_cell(board, violates);
		
		if (k>0) std::cout << std::endl;
		for (int i=0; i<BOARD_SIZE; i++) {
			for (int j=0; j<BOARD_SIZE; j++) {
				if (violates[i][j]) std::cout << "*";
				else std::cout << " ";
				std::cout << board[i][j];
			}
			std::cout << std::endl;
		}
	}
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, t[10][10];

int main(){
	cin >> n;
	REP(i, n){
		REP(i, 9)REP(j, 9)cin >> t[i][j];
		REP(i, 9){
			REP(j, 9){
				bool f = 0;
				REP(k, 9){
					if (j == k)continue;
					if (t[i][k] == t[i][j])f = 1;
				}
				REP(k, 9){
					if (i == k)continue;
					if (t[k][j] == t[i][j])f = 1;
				}
				REP(k, 3){
					REP(l, 3){
						if (i / 3 * 3 + k == i&&j / 3 * 3 + l == j)continue;
						if (t[i / 3 * 3 + k][j / 3 * 3 + l] == t[i][j])f == 1;
					}
				}
				f ? cout << "*" : cout << " ";
				cout << t[i][j];
			}
			cout << endl;
		}
	}
}

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

int mat[9][9];
bool judge[9][9];

int main(){
    int n;
    cin >> n;

    for(int x = 0; x < n; x++){
        if(x)   cout << endl;

        for(int i = 0; i < 9; i++){
            for(int j = 0; j < 9; j++){
                cin >> mat[i][j];
                judge[i][j] = false;
            }
        }

        // horizontal
        for(int i = 0; i < 9; i++){
            int cnt[10] = {};
            for(int j = 0; j < 9; j++){
                cnt[mat[i][j]]++;
            }
            for(int j = 0; j < 9; j++){
                if(cnt[mat[i][j]] > 1)  judge[i][j] = true;
            }
        }

        // vertital
        for(int i = 0; i < 9; i++){
            int cnt[10] = {};
            for(int j = 0; j < 9; j++){
                cnt[mat[j][i]]++;
            }
            for(int j = 0; j < 9; j++){
                if(cnt[mat[j][i]] > 1)  judge[j][i] = true;
            }
        }

        // box
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                int cnt[10] = {};
                for(int k = 0; k < 3; k++){
                    for(int l = 0; l < 3; l++){
                        cnt[mat[3*i + k][3*j + l]]++;
                    }
                }
                for(int k = 0; k < 3; k++){
                    for(int l = 0; l < 3; l++){
                        if(cnt[mat[3*i + k][3*j + l]] > 1)
                            judge[3*i + k][3*j + l] = true;
                    }
                }
            }
        }
        
        for(int i = 0; i < 9; i++){
            for(int j = 0; j < 9; j++){
                if(judge[i][j]) cout << "*";
                else            cout << " ";
                cout << mat[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}