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 <vector>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	bool first = true;
	while(n--)
	{
		if(!first)
		{
			cout << endl;
		}
		first = false;
		char field[9][9];
		char isWrong[9][9];
		for(int i = 0; i < 9; ++i)
		{
			for(int j = 0; j < 9; ++j)
			{
				cin >> field[i][j];
				isWrong[i][j] = ' ';
			}
		}
		for(int i = 0; i < 9; ++i)
		{
			vector<int> count(10);
			bool flag = false;
			for(int j = 0; j < 9; ++j)
			{
				++count[field[i][j] - '0'];
				if(count[field[i][j] - '0'] >= 2)
				{
					flag = true;
				}
			}
			if(flag)
			{
				for(int j = 1; j < 10; ++j)
				{
					if(count[j] >= 2)
					{
						for(int k = 0; k < 9; ++k)
						{
							if(field[i][k] == j + '0')
							{
								isWrong[i][k] = '*';
							}
						}
					}
				}
			}
		}
		
		for(int i = 0; i < 9; ++i)
		{
			vector<int> count(10);
			bool flag = false;
			for(int j = 0; j < 9; ++j)
			{
				++count[field[j][i] - '0'];
				if(count[field[j][i] - '0'] >= 2)
				{
					flag = true;
				}
			}
			if(flag)
			{
				for(int j = 1; j < 10; ++j)
				{
					if(count[j] >= 2)
					{
						for(int k = 0; k < 9; ++k)
						{
							if(field[k][i] == j + '0')
							{
								isWrong[k][i] = '*';
							}
						}
					}
				}
			}
		}

		for(int i = 0; i < 3; ++i)
		{
			for(int j = 0; j < 3; ++j)
			{
				int count[10] = {};
				bool flag = false;
				for(int k = 0; k < 3; ++k)
				{
					for(int l = 0; l < 3; ++l)
					{
						++count[field[3 * i + k][3 * j + l] - '0'];
						if(count[field[3 * i + k][3 * j + l] - '0'] >= 2)
						{
							flag = true;
						}
					}
				}
				if(flag)
				{
					for(int k = 1; k < 10; ++k)
					{
						if(count[k] >= 2)
						{
							for(int l = 0; l < 3; ++l)
							{
								for(int m = 0; m < 3; ++m)
								{
									if(field[3 * i + l][3 * j + m] == k + '0')
									{
										isWrong[3 * i + l][3 * j + m] = '*';
									}
								}
							}
						}
					}
				}
			}
		}
		for(int i = 0; i < 9; ++i)
		{
			for(int j = 0; j < 9; ++j)
			{
				cout << isWrong[i][j] << field[i][j];
			}
			cout << endl;
		}
	}
}

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

C++: #include <iostream>
using namespace std;
#define REP(i,b,c) for(int i=0;i<b;i+=c)

int main(){
	char p[9][9];
	int n;
	cin >> n;
	while(n--){
		char a[9][9];
		REP(i,9,1)REP(j,9,1)a[j][i]=' ';
		REP(i,9,1)REP(j,9,1)cin >> p[j][i];
		
		REP(j,9,3){
			REP(i,9,3){			
				int c[9]={0};
				REP(x,3,1){
					REP(y,3,1){
						c[p[i+x][j+y]-'0'-1]++;
						if(c[p[i+x][j+y]-'0'-1]>1){
							REP(t,3,1){
								REP(l,3,1){
									if(p[i+x][j+y]==p[i+t][j+l]){
										a[i+t][j+l]='*';
									}
								}
							}
						}
					}
				}	
			}
		}
		REP(i,9,1){
			int c[9]={0},c2[9]={0};
			REP(j,9,1){
				c[p[j][i]-'0'-1]++;
				if(c[p[j][i]-'0'-1]>1){
					REP(t,9,1){
						if(p[j][i]==p[t][i]){
							a[t][i]='*';
						}
					}
				}
				c2[p[i][j]-'0'-1]++;
				if(c2[p[i][j]-'0'-1]>1){
					REP(t,9,1){
						if(p[i][j]==p[i][t]){
							a[i][t]='*';
						}
					}
				}
			}
		}
		REP(i,9,1){
			REP(j,9,1)cout << a[j][i] << p[j][i];
			cout << endl;
		}
		if(n)cout << endl;
	}
}

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<iostream>
#include<string>
using namespace std;
bool a[9][9];
int c[9][9];
int main() {
	int n;
	cin >> n;
	string b;
	getline(cin, b);
	for (int x = 0; x < n; x++) {
		int d[10];
		int k;
		for (int i = 0; i < 9; i++) {
			getline(cin, b);
			for (int j = 0; j < b.length(); j+=2) {
				c[i][j / 2] = (int)b[j] - '0';
				a[i][j] = false;
			}
			if (i == 0) k = c[0][0];
			fill(d, d + 10, 0);
			for (int j = 0; j < 9; j++) 
				d[c[i][j]]++;
			for (int j = 0; j < 9; j++) {
				if (d[c[i][j]] > 1) 
					a[i][j] = true;
			}
		}
		c[0][0] = k;
		for (int i = 0; i < 9; i++) {
			fill(d, d + 10, 0);
			for (int j = 0; j < 9; j++)
				d[c[j][i]]++;
			for (int j = 0; j < 9; j++) {
				if (d[c[j][i]]>1)
					a[j][i] = true;
			}
		}
		for (int i = 0; i < 9; i += 3) {
			for (int j = 0; j < 9; j += 3) {
				fill(d, d + 10, 0);
				for (int z = i; z < i + 3; z++) {
					for (int y = j; y < j + 3; y++) {
						d[c[z][y]]++;
					}
				}
				for (int z = i; z < i + 3; z++) {
					for (int y = j; y < j + 3; y++) {
						if (d[c[z][y]] > 1) {
							a[z][y] = true;
						}
					}
				}
			}
		}
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				if (a[i][j])
					cout << "*" << c[i][j];
				else
					cout << " " << c[i][j];
			}
			cout << endl;
		}
		if (x < n-1) {
			cout << endl;
		}
	}
}