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 <iostream>
#include <stdio.h>
#include <utility>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef pair<int,int> p;
int cen[]={1,4,7};
int main()
{
    int n;
	cin>>n;
	while(n--){
		int a[9][9];
		bool cor[9][9];
		
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++){
				cin>>a[i][j];
				cor[i][j]=true;
			}
		for(int i=0;i<9;i++){
			int check[9]={};
			for(int j=0;j<9;j++)check[a[i][j]-1]++;
			for(int j=0;j<9;j++)if(check[a[i][j]-1]!=1)cor[i][j]=false;
		}
		for(int i=0;i<9;i++){
			int check[9]={};
			for(int j=0;j<9;j++)check[a[j][i]-1]++;
			for(int j=0;j<9;j++)if(check[a[j][i]-1]!=1)cor[j][i]=false;
		}
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++){
				int check[9]={};
				for(int kx=-1;kx<=1;kx++)
					for(int ky=-1;ky<=1;ky++){
						int nx=cen[i]+kx,ny=cen[j]+ky;
						check[a[nx][ny]-1]++;
					}
					if(check[a[i][j]-1]!=1)cor[i][j]=false;
			}
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				printf(cor[i][j]?" %d":"*%d",a[i][j]);
			}
			cout<<endl;
		}
		if(n!=0)cout<<endl;
	}
    return 0;
}

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" : "");
			
	}
}

C++: #include <stdio.h>
int n, a[9][9], r[9][9];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) scanf("%d", &a[j][k]), r[j][k] = 0;
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				for (int l = 0; l < 9; l++) {
					if (k != l && a[j][k] == a[j][l]) r[j][k] = 1;
					if (j != l && a[j][k] == a[l][k]) r[j][k] = 1;
				}
				for (int l = j / 3 * 3; l < j / 3 * 3 + 3; l++) {
					for (int m = k / 3 * 3; m < k / 3 * 3 + 3; m++) {
						if (j != l && k != m && a[j][k] == a[l][m]) r[j][k] = 1;
					}
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) printf("%c%d", r[j][k] ? '*' : ' ', a[j][k]);
			printf("\n");
		}
	}
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int x[9][9], n, s[10], cnt[9][10], p[9][9]; bool a[9][9];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		memset(x, 0, sizeof(x));
		memset(p, 0, sizeof(p));
		memset(a, false, sizeof(a));
		memset(cnt, 0, sizeof(cnt));
		if (i) { cout << endl; }
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				cin >> x[j][k];
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[j][k]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[j][k]] >= 2) {
					a[j][k] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[k][j]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[k][j]] >= 2) {
					a[k][j] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				p[(j / 3) * 3 + (k / 3)][cnt[j][(j / 3) * 3 + (k / 3)]] = x[j][k];
				cnt[j][(j / 3) * 3 + (k / 3)]++;
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[j][k]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[j][k]] >= 2) {
					a[j][k] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				if (a[j][k] == true) {
					cout << '*';
				}
				else {
					cout << ' ';
				}
				cout << x[j][k];
			}
			cout << endl;
		}
	}
}

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

bool ok[9][9];
int m[9][9];

void reset(int *r){
	for(int i = 0; i < 10; ++i)
		*(r + i) = 0;
}

void func(int x, int y){
	int cn[10] = {};
	for(int i = x; i < x + 3; ++i)
		for(int j = y; j < y + 3; ++j)
			cn[m[i][j]]++;
			
	for(int i = x; i < x + 3; ++i){
		for(int j = y; j < y + 3; ++j){
			if(cn[m[i][j]] >= 2)
				ok[i][j] = true;
		}
	}
}
int main() {
	int n;
	cin >> n;
	for(int c = 0; c < n; ++c){
		for(int i = 0; i < 9; ++i)
			for(int j = 0; j < 9; ++j)
				ok[i][j] = false;
			
		for(int i = 0; i < 9; ++i)
			for(int j = 0; j < 9; ++j)
				cin >> m[i][j];
		
		int cnt[10] = {0};
		for(int i = 0; i < 9; ++i){
			for(int j = 0; j < 9; ++j)
				cnt[m[j][i]]++;
				
			for(int j = 0; j < 9; ++j){
			if(cnt[m[j][i]] >= 2)
				ok[j][i] = true;
			}
			reset(cnt);
		}
	
		for(int i = 0; i < 9; ++i){
			for(int j = 0; j < 9; ++j)
				cnt[m[i][j]]++;
				
			for(int j = 0; j < 9; ++j){
				if(cnt[m[i][j]] >= 2)
					ok[i][j] = true;
			}
			reset(cnt);
		}
		
		for(int i = 0; i < 9; i += 3)
			for(int j = 0; j < 9; j += 3)
				func(i, j);
				
		for(int i = 0; i < 9; ++i){
			for(int j = 0; j < 9; ++j){
				if(ok[i][j])
					cout << "*";
				else
					cout << " ";
				cout << m[i][j];
			}
			cout << endl;
		}
		if(c != n - 1)
			cout << endl;
	}
	return 0;
}