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 <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int field[10][10], used[10];
	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++)
			{
				//printf("%d%s",used[j] ,(j == 9)?"\n":" ");
				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.h>

using namespace std;
const int N = 9;
void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		char Field[N][N];
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				cin >> Field[i][j];
			}
		}
		bool Flag[N][N];
		memset(Flag, 1, sizeof(Flag));
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				if(Flag[i][j])
				{
					for(int a = 0; a < N; ++a)
					{
						if(i != a && Field[a][j] == Field[i][j])
						{
							Flag[i][j] = Flag[a][j] = false;
						}
					}
					for(int a = 0; a < N; ++a)
					{
						if(j != a && Field[i][a] == Field[i][j])
						{
							Flag[i][j] = Flag[i][a] = false;
						}
					}
					int x = j / 3;
					x *= 3;
					int y = i / 3;
					y *= 3;
					for(int a = x; a < x + 3; ++a)
					{
						for(int b = y; b < y + 3; ++b)
						{
							if(a != j && b != i && Field[b][a] == Field[i][j])
							{
								Flag[b][a] = Flag[i][j] = false;
							}
						}
					}
				}
			}
		}
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				if(Flag[i][j] == false)
				{
					cout << '*';
				}
				else
				{
					cout << ' ';
				}
				cout << Field[i][j];
			}
			cout << endl;
		}
		if(n != 0)
			cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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++){
		if(t > 0){
			cout << endl;
		}
		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;
		}
		
		for(int i = 0; i < 9; i++){
			free(array[i]);
			free(array2[i]);
		}
		free(array);
		free(array2);
	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int dx[] = {0,0,0,1,1,1,2,2,2};
int dy[] = {0,1,2,0,1,2,0,1,2};

int main(){
	int N;cin >> N;
	while(N--){
		int data[9][9];
		bool bad[9][9] = {0};
		rep(i,9)rep(j,9)cin >> data[i][j];
		
		rep(i,3)rep(j,3){
			rep(d,9){
				int sx = j*3+dx[d] , sy = i*3+dy[d];
				rep(k,9){
					int tx = j*3+dx[k] , ty = i*3+dy[k];
					if(tx == sx && ty == sy)continue;
					if(data[sy][sx] == data[ty][tx])bad[sy][sx] = true;
				}
			}
		}
		
		rep(i,9){
			rep(j,9){
				rep(k,9){
					if(j == k)continue;
					if(data[i][j] == data[i][k])bad[i][j] = true;
				}
			}
		}
		rep(j,9){
			rep(i,9){
				rep(k,9){
					if(i == k)continue;
					if(data[i][j] == data[k][j])bad[i][j] = true;
				}
			}
		}
		rep(i,9){
			rep(j,9){
				cout << (bad[i][j]?"*":" ") << data[i][j];
			}
			cout << endl;
		}
		if(N)cout << endl;
	}
}