Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)
	for 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 <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n,m[9][9],f[9][9];

int main(){
	cin>>n;
	while(n--){
		memset(f,0,sizeof(f));
		rep(i,9)rep(j,9)cin>>m[i][j];
		rep(i,9){
			rep(j,9)rep2(k,j+1,9){
				if(m[i][j]==m[i][k])f[i][j]=f[i][k]=1;
				if(m[j][i]==m[k][i])f[j][i]=f[k][i]=1;
			}
		}
		rep(i,3)rep(j,3){
			rep(ii,3)rep(jj,3)rep(iii,3)rep(jjj,3){
				if((ii!=iii||jj!=jjj)&&m[i*3+ii][j*3+jj]==m[i*3+iii][j*3+jjj]){
					f[i*3+ii][j*3+jj]=f[i*3+iii][j*3+jjj]=1;
				}
			}
		}
		rep(i,9){
			rep(j,9)cout<<(f[i][j]?"*":" ")<<m[i][j];
			cout<<endl;
		}
		if(n)cout<<endl;
	}
}

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

int main() {
	int n;
	cin >> n;
	bool flag = false;

	for(int i = 0; i < n; i++) {
		int board[16][16];
		char mark[16][16];
		memset(mark, ' ', sizeof(mark));
		for(int j = 0; j < 9; j++)
			for(int k = 0; k < 9; k++)
				cin >> board[j][k];

		// row & comlumn
		for(int j = 0; j < 9; j++) {
			for(int k = 0; k < 9; k++) {
				for(int l = k + 1; l < 9; l++) {
					if(board[j][k] == board[j][l])
						mark[j][k] = mark[j][l] = '*';
					if(board[k][j] == board[l][j])
						mark[k][j] = mark[l][j] = '*';
				}
			}
		}

		// block
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				for(int l = 0; l < 3; l++) {
					for(int m = 0; m < 3; m++) {
						for(int n = l + 1; n < 3; n++) {
							for(int o = m + 1; o < 3; o++) {
								if(board[j * 3 + l][k * 3 + m] == board[j * 3 + n][k * 3 + o])
									mark[j * 3 + l][k * 3 + m] = mark[j * 3 + n][k * 3 + o] = '*';
							}
						}
					}
				}
			}
		}

		if(flag)
			cout << endl;

		for(int j = 0; j < 9; j++) {
			for(int k = 0; k < 9; k++) {
				cout << mark[j][k] << board[j][k];
			}
			cout << endl;
		}

		flag = true;
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int math[9][9], jud[10] = {};
bool mmath[9][9];
void jj(int x, int y){
	int jud2[10][2];
	for(int i = 0; i < 10; i++){
		fill(jud2[i], jud2[i] + 2, -1);
	}
	for(int i = x; i < x + 3; i++){
		for(int j = y; j < y + 3; j++){
			if(jud2[math[i][j]][0] >= 0){
				mmath[i][j] = 1;
				mmath[jud2[math[i][j]][0]][jud2[math[i][j]][1]] = 1;;
			}
			jud2[math[i][j]][0] = i;
			jud2[math[i][j]][1] = j;
		}
	}
}
int main(){
	int n;
	cin >> n;
	for(int k = 0; k < n; k++){
		for(int i = 0; i < 9; i++)
			fill(mmath[i], mmath[i] + 9, 0);
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				cin >> math[i][j];
			}
		}
		for(int i = 0; i < 9; i++){
			fill(jud, jud + 10, -1);
			for(int j = 0; j < 9; j++){
				if(jud[math[i][j]] >= 0){
					mmath[i][j] = 1;
					mmath[i][jud[math[i][j]]] = 1;
				}
				jud[math[i][j]] = j;
			}
		}
		for(int i = 0; i < 9; i++){
			fill(jud, jud + 10, -1);
			for(int j = 0; j < 9; j++){
				if(jud[math[j][i]] >= 0){
					mmath[j][i] = 1;
					mmath[jud[math[j][i]]][i] = 1;
				}
				jud[math[j][i]] = j;
			}
		}
		jj(0, 0);	jj(3, 0);	jj(6, 0);
		jj(0, 3);	jj(3, 3);	jj(6, 3);
		jj(0, 6);	jj(3, 6);	jj(6, 6);
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				if(!mmath[i][j])
					cout << ' ';
				else
					cout << '*';
				cout << math[i][j];
			}
			cout << endl;
		}
		cout << endl;
	}
}

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

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int sudoku[10][10];

bool ok(int a,int b){
	int i,j;
	for(i=0;i<9;i++){
		if(i!=a&&sudoku[a][b]==sudoku[i][b])return false;
	}
	for(i=0;i<9;i++){
		if(i!=b&&sudoku[a][b]==sudoku[a][i])return false;
	}
	for(i=a/3*3;i<a/3*3+3;i++){
		for(j=b/3*3;j<b/3*3+3;j++){
			if(i!=a&&j!=b&&sudoku[a][b]==sudoku[i][j])return false;
		}
	}
	return true;
}

int main() {
	int n=in();
	int i;
	for(i=0;i<n;i++){
		if(i>0)cout<<endl;
		int a,b;
		for(a=0;a<9;a++){
			for(b=0;b<9;b++){
				cin>>sudoku[a][b];
			}
		}
		for(a=0;a<9;a++){
			for(b=0;b<9;b++){
				if(ok(a,b)){
					cout<<" "<<sudoku[a][b];
				}else{
					cout<<"*"<<sudoku[a][b];
				}
			}
			cout<<endl;
		}
	}
	return 0;
}