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>
#include <stdlib.h>

using namespace std;

int dir[9][2] = {
	{-1, -1},
	{0, -1},
	{1, -1},
	{-1, 0},
	{0, 0},
	{1, 0},
	{-1, 1},
	{0, 1},
	{1, 1}
};

int main(int argc, char **argv)
{
	int **array, **array2, *array3, n;
	
	cin >> n;
	for(int t = 0; t < n; t++){
		array = (int **)calloc(9, sizeof(int));
		array2 = (int **)calloc(9, sizeof(int));
		for(int i = 0; i < 9; i++){
			array[i] = (int *)calloc(9, sizeof(int));
			array2[i] = (int *)calloc(9, sizeof(int));
		}
		
		for(int i = 0; i < 9; i++){
			array3 = (int *)calloc(10, sizeof(int));
			for(int j = 0; j < 9; j++){
				cin >> array[i][j];
				array3[array[i][j]]++;
			}
			
			for(int k = 1; k <= 9; k++){
				if(array3[k] > 1){
					for(int j = 0; j < 9; j++){
						if(k == array[i][j]){
							array2[i][j] = 1;
						}
					}
				}
			}
			
			free(array3);
		}
		
		for(int i = 0; i < 9; i++){
			array3 = (int *)calloc(10, sizeof(int));
			for(int j = 0; j < 9; j++){
				array3[array[j][i]]++;
			}
			
			for(int k = 1; k <= 9; k++){
				if(array3[k] > 1){
					for(int j = 0; j < 9; j++){
						if(k == array[j][i]){
							array2[j][i] = 1;
						}
					}
				}
			}
			free(array3);
		}
		
		for(int i = 1; i < 9; i+=3){
			for(int j = 1; j < 9; j+=3){
				array3 = (int *)calloc(10, sizeof(int));
				for(int k = 0; k < 9; k++){
					array3[array[i+dir[k][0]][j+dir[k][1]]]++;
				}
				
				for(int k = 1; k <= 9; k++){
					if(array3[k] > 1){
						for(int l = 0; l < 9; l++){
							if(k == array[i+dir[l][0]][j+dir[l][1]]){
								array2[i+dir[l][0]][j+dir[l][1]] = 1;
							}
						}
					}
				}
				
				free(array3);
			}
		}
		
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				if(array2[i][j] == 0){
					cout << " " << array[i][j];
				} else {
					cout << "*" << array[i][j];
				}
			}
			cout << endl;
		}
		cout << endl;
		
		for(int i = 0; i < 9; i++){
			free(array[i]);
			free(array2[i]);
		}
		free(array);
		free(array2);
	}
	
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<regex>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int n; cin >> n;
	int m[9][9];
	bool b[9][9] = {};
	bool first = true;
	rep(h, 0, n) {
		if (!first)cout << endl;
		first = false;
		rep(i, 0, 9)rep(j, 0, 9)cin >> m[i][j];

		rep(i, 0, 9) {
			int cnt[10] = {};
			rep(j, 0, 9)cnt[m[i][j]]++;
			rep(j, 0, 9) {
				if (cnt[m[i][j]] >= 2)b[i][j] = true;
			}
		}
		rep(j, 0, 9) {
			int cnt[10] = {};
			rep(i, 0, 9)cnt[m[i][j]]++;
			rep(i, 0, 9) {
				if (cnt[m[i][j]] >= 2)b[i][j] = true;
			}
		}
		for (int i = 0; i < 9; i += 3) {
			for (int j = 0; j < 9; j += 3) {
				int cnt[10] = {};
				rep(I, i, i + 3)rep(J, j, j + 3) {
					cnt[m[I][J]]++;
				}
				rep(I, i, i + 3)rep(J, j, j + 3) {
					if (cnt[m[I][J]] >= 2)b[I][J] = true;
				}
			}
		}
		rep(i, 0, 9) {
			rep(j, 0, 9) {
				if (b[i][j])cout << "*";
				else cout << " ";
				cout << m[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

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

int f[9][9];
bool t[9][9];

void check(int x, int y)
{
	for(int i=0; i<9; i++)
	{
		if(i!=x&&f[i][y]==f[x][y])
		{
			t[i][y]=1;
			t[x][y]=1;
		}
		if(i!=y&&f[x][i]==f[x][y])
		{
			t[x][i]=1;
			t[x][y]=1;
		}
	}
	for(int i=3*(y/3); i<3*((y/3)+1); i++)
	for(int j=3*(x/3); j<3*((x/3)+1); j++)
	{
		if(j==x&&i==y) continue;
		if(f[j][i]==f[x][y])
		{
			t[j][i]=1;
			t[x][y]=1;
		}
	}
}

int main()
{
	int N;
	scanf("%d", &N);
	for(int k=0; k<N; k++)
	{
		if(k!=0) puts("");

		for(int i=0; i<9; i++)
		for(int j=0; j<9; j++)
		{
			scanf("%d", &f[j][i]);
			t[j][i]=0;
		}
			
		for(int i=0; i<9; i++)
		{
			for(int j=0; j<9; j++)
			{
				check(j,i);
				printf((t[j][i]?"*":" "));
				printf("%d", f[j][i]);
			}
			puts("");
		}
	}
}

C++: #include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;

const int N = 9;
int a[N][N];

vector<int> F(int x,int y)
{
	vector<int> r;
	int i,j;
	for(i=0;i<3;++i)
		for(j=0;j<3;++j)
			r.push_back(a[x/3*3+i][y/3*3+j]);
	return r;
}
int main(void)
{
	int n,i,j,k,x=0;
	bool b;
	vector<int>v;
	
	scanf("%d",&n);
	while(n--)
	{
		for(i=0;i<N;++i)
			for(j=0;j<N;++j)
				scanf("%d",&a[i][j]);

		printf("%s",(x++?"\n":""));
		for(i=0;i<N;++i)
		{
			for(j=0;j<N;++j)
			{
				b=false;
				v=F(i,j);
				if(count(v.begin(),v.end(),a[i][j])>1 ||
					count(a[i],a[i]+N,a[i][j]) > 1)
					b=true;
				else
				{
					for(k=0;k<N;++k)
					{
						if(k==i)continue;
						if(a[i][j] == a[k][j]) b=true;
					}
				}
				printf("%c%d",(b?'*':' '),a[i][j]);
			}
			putchar('\n');
		}
	}
	return 0;
}