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<cstring>
using namespace std;
int x[9][9], n, s[10], cnt[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 (n) { 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 / 3) * 3 + (k / 3)]] = x[j][k];
				cnt[(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 <stdio.h>
int n, a[9][9], r[9][9];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		if (i) printf("\n");
		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++: int main()
{
        //field : ????????°??¬?????¶???
        //used : ???????????????????????????????????????????????°?????????????????????
	int field[10][10], used[10];
        //judge : ??°??¬???????????£???????????¨?????????true???
	bool judge[10][10];

	int num;
	cin >> num;
	while(num--)
	{
		memset(judge, false, sizeof(judge));

		for(int i = 0; i < 9; i++)
		{
			for(int j = 0; j< 9; j++)
			{
				cin >> field[i][j];
			}
		}
		for(int i = 0; i < 9; i++)
		{
			memset(used, 0, sizeof(used));
			for(int j = 0; j < 9; j++)
			{
				used[field[i][j]]++;
			}
			for(int j = 1; j <=9; j++)
			{
				if(used[j] >= 2)
				{
					for(int k = 0; k < 9; k++)
					{
						if(field[i][k] == j)
						{
							judge[i][k] = true;
						}
					}
				}
			}
			memset(used, 0, sizeof(used));
			for(int j = 0; j < 9; j++)
			{
				used[field[j][i]]++;
			}
			for(int j = 1; j<= 9; j++)
			{
				if(used[j] >= 2)
				{
					for(int k = 0; k < 9; k++)
					{
						if(field[k][i] == j)
						{
							judge[k][i] = true;
						}
					}
				}
			}
		}

		for(int l = 0; l < 9; l+=3)
		{
			for(int m = 0; m < 9; m+=3)
			{
				memset(used, false, sizeof(used));
				for(int i = 0; i < 3; i++)
				{
					for(int j = 0; j < 3; j++)
					{
						used[field[i+l][j+m]]++;
					}
				}

				for(int n = 1; n <=9; n++)
				{
					if(used[n] >= 2)
					{
						for(int i = 0; i < 3; i++)
						{
							for(int j = 0; j < 3; j++)
							{
								if(field[i+l][j+m] == n)
								{
									judge[i+l][j+m] = true;
								}
							}
						}
					}
				}
			}
		}

		for(int i = 0; i < 9; i++)
		{
			for(int j = 0; j < 9; j++)
			{
				printf("%s%d",(judge[i][j])?"*":" " ,field[i][j]);
			}
			puts("");
		}
		if(num != 0)
		{
			puts("");
		}
	}
}

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;
	bool g = 0;
	REP(i, n){
		if (g)cout << endl;
		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;
				}
				//cout << endl;
				REP(k, 3){
					REP(l, 3){
						//cout << i / 3 * 3 + k << " " << j / 3 * 3 + l << endl;
						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;
		}
		g = 1;
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	bool r=false;
	while(n--){
	if(r)cout<<endl;
	r=true;
	int a[9][9];
	bool d[9][9]={0};
	for(int i=0;i<9;i++){
		for(int j=0;j<9;j++){
			cin>>a[i][j];
			a[i][j]--;
		}
	}
	int t[9];
	for(int i=0;i<9;i++){
		for(int j=0;j<9;j++)t[j]=0;
		for(int j=0;j<9;j++)t[a[i][j]]++;
		for(int j=0;j<9;j++)if(t[j]>1)for(int k=0;k<9;k++)if(a[i][k]==j)d[i][k]=true;
	}
	for(int i=0;i<9;i++){
		for(int j=0;j<9;j++)t[j]=0;
		for(int j=0;j<9;j++)t[a[j][i]]++;
		for(int j=0;j<9;j++)if(t[j]>1)for(int k=0;k<9;k++)if(a[k][i]==j)d[k][i]=true;
	}
	for(int f=0;f<9;f+=3){
		for(int g=0;g<9;g+=3){
			for(int i=0;i<9;i++)t[i]=0;
			for(int i=0;i<3;i++)for(int j=0;j<3;j++)t[a[i+f][j+g]]++;
			for(int k=0;k<9;k++)if(t[k]>1){
				for(int i=0;i<3;i++)for(int j=0;j<3;j++){
					if(a[i+f][j+g]==j)d[i+f][j+g]=true;
				}
			}
		}
	}
	for(int i=0;i<9;i++){
		for(int j=0;j<9;j++){
			if(d[i][j])cout<<"*";
			else cout<<" ";
			cout<<a[i][j]+1;
		}
		cout<<endl;
	}
	}
	return 0;
}