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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	cin >> n;
	
	while(n--)
	{
		vector<vint> table(9, vint(9));
		
		rep(y, 9) rep(x, 9)
		{
			cin >> table[y][x];
			table[y][x]--;
		}
		
		vector<bitset<9> > flags(9);
		
		// ツ行
		rep(y, 9) 
		{
			vint v(9, 0);
			rep(x, 9)
			{
				v[table[y][x]]++;
			}
			
			rep(x, 9)
			{
				flags[y][x] = 1 < v[table[y][x]];
			}
		}
		
		// ツ療ア
		rep(x, 9) 
		{
			vint v(9, 0);
			rep(y, 9)
			{
				v[table[y][x]]++;
			}
			
			rep(y, 9)
			{
				flags[y][x] = flags[y][x] || 1 < v[table[y][x]];
			}
		}
		
		
		// square
		rep(y, 3) rep(x, 3) 
		{
			vint v(9, 0);
			rep(yy, 3) rep(xx, 3)
			{
				v[table[y * 3 + yy][x * 3 + xx]]++;
			}
			
			rep(yy, 3) rep(xx, 3)
			{
				flags[y * 3 + yy][x * 3 + xx] = flags[y * 3 + yy][x * 3 + xx] || 1 < v[table[y * 3 + yy][x * 3 + xx]];
			}
		}
		
		
		// print
		rep(y, 9) rep(x, 9)
			cout << (flags[y][x] ? "*" : " ") << table[y][x] + 1 << (x == 8 ? "\n" : "");
		
		if(n) cout << endl;
			
	}
}

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

int N;
struct Pos {
	int x, y;
};

int main() {
	scanf(" %d", &N);
	for(int i = 0; i < N; i++) {
		// arr[y][x]
		int arr[9][9];
		bool fail[9][9];
		memset(fail, 0, sizeof fail);

		for(int y = 0; y < 9; y++) {
			for(int x = 0; x < 9; x++) {
				scanf(" %d", &arr[y][x]);
			}
		}
		for(int x = 0; x < 9; x++) {
			int count[10];
			memset(count, 0, sizeof count);
			for(int y = 0; y < 9; y++) {
				count[arr[y][x]]++;
			}
			for(int i = 1; i <= 9; i++) {
				if(count[i] != 1) {
					for(int y = 0; y < 9; y++) {
						if(arr[y][x] == i)
							fail[y][x] = true;
					}
				}
			}
		}

		for(int y = 0; y < 9; y++) {
			int count[10];
			memset(count, 0, sizeof count);
			for(int x = 0; x < 9; x++) {
				count[arr[y][x]]++;
			}
			for(int i = 1; i <= 9; i++) {
				if(count[i] != 1) {
					for(int x = 0; x < 9; x++) {
						if(arr[y][x] == i)
							fail[y][x] = true;
					}
				}
			}
		}

		Pos p[9] = {{1, 1}, {1, 4}, {1, 7}, {4, 1}, {4, 4}, {4, 7}, {7, 1}, {7, 4}, {7, 7}};
		for(int i = 0; i < 9; i++) {
			int cx = p[i].x;
			int cy = p[i].y;
			int count[10];
			memset(count, 0, sizeof count);
			for(int x = -1; x <= 1; x++) {
				for(int y = -1; y <= 1; y++) {
					int nx = cx + x;
					int ny = cy + y;
					count[arr[ny][nx]]++;
				}
			}
			for(int j = 1; j <= 9; j++) {
				if(count[j] != 1) {
					for(int x = -1; x <= 1; x++) {
						for(int y = -1; y <= 1; y++) {
							int nx = cx + x;
							int ny = cy + y;
							if(arr[ny][nx] == j) {
								fail[ny][nx] = true;
							}
						}
					}
				}
			}
		}

		for(int y = 0; y < 9; y++) {
			for(int x = 0; x < 9; x++) {
				putchar(fail[y][x] ? '*' : ' ');
				printf("%d", arr[y][x]);
			}
			puts("");
		}
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int G[9][9], wrong[9][9];
int cnt[9];

int main() {
    int t;
    cin >> t;
    int a = 0;
    while(t--){
        if(a++) puts("");
        for (int i = 0; i < 9; ++i) {
            for (int j = 0; j < 9; ++j) {
                cin >> G[i][j];
                G[i][j]--;
                wrong[i][j] = 0;
            }
        }
        fill(cnt, cnt+9, 0);
        for (int i = 0; i < 9; ++i) {
            fill(cnt, cnt+9, 0);
            for (int j = 0; j < 9; ++j) cnt[G[i][j]]++;
            for (int j = 0; j < 9; ++j) if(cnt[G[i][j]] >= 2) wrong[i][j] = 1;
        }
        for (int i = 0; i < 9; ++i) {
            fill(cnt, cnt+9, 0);
            for (int j = 0; j < 9; ++j) cnt[G[j][i]]++;
            for (int j = 0; j < 9; ++j) if(cnt[G[j][i]] >= 2) wrong[j][i] = 1;
        }
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                fill(cnt, cnt+9, 0);
                for (int k = 0; k < 3; ++k) {
                    for (int l = 0; l < 3; ++l) {
                        cnt[G[i*3+k][j*3+l]]++;
                    }
                }
                for (int k = 0; k < 3; ++k) {
                    for (int l = 0; l < 3; ++l) {
                        if(cnt[G[i*3+k][j*3+l]] >= 2) wrong[i*3+k][j*3+l] = 1;
                    }
                }
            }
        }
        for (int i = 0; i < 9; ++i) {
            for (int j = 0; j < 9; ++j) {
                putchar(wrong[i][j] ? '*' : ' ');
                printf("%d", G[i][j]+1);
            }
            puts("");
        }
    }
    return 0;
}