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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int board[10][10];
int main(){
	cin>>n;
	for(int k = 0;k< n;k++){
		bool flag[10][10];
		rep(i,10){
			rep(j,10){
				flag[i][j] = true;
			}
		}
		for(int y = 1;y <=9;y++){
			for(int x = 1;x <=9;x++){
				cin>>board[y][x];
			}
		}
		for(int y = 1; y<=9;y+=3){//3×3ブロックごとの判定
			for(int x = 1;x <=9;x+=3){
				int cnt[10]={0};
				rep(i,3){
					rep(j,3){
						cnt[board[y+i][x+j]]+=1;
					}
				}
				rep(i,3){
					rep(j,3){
						if(cnt[board[y+i][x+j]]!=1){
							flag[y+i][x+j] =false;
						}
					}
				}
			}
		}
		for(int y = 1;y <=9;y++){//横の判定
			int cnt[10]={0};
			for(int x = 1;x <=9;x++){
				cnt[board[y][x]]+=1;
			}
			for(int x = 1; x<=9;x++){
				if(cnt[board[y][x]]!=1){
					flag[y][x] =false;
				}
			}
		}
		for(int x = 1;x <=9;x++){
			int cnt[10]={0};
			for(int y =1;y <=9;y++){
				cnt[board[y][x]]++;
			}
			for(int y = 1;y <=9;y++){
				if(cnt[board[y][x]]!=1){
					flag[y][x] = false;
				}
			}
		}
		for(int i = 1;i <=9;i++){
			for(int j = 1;j <=9;j++){
				printf("%c%d",(flag[i][j]?' ':'*'),board[i][j]);
			}
			puts("");
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

int n;
int masu[9][9];
bool wrong[9][9];

int main()
{
	cin >> n;

	while (n--)
	{
		memset(wrong, 0, sizeof(wrong));

		rep(i, 9) rep(j, 9)	cin >> masu[i][j];
	
		//横
		rep(i, 9) rep(j, 9) rep(k, 9)
		{
			if (masu[i][j] == masu[i][k] && j != k) wrong[i][j] = wrong[i][k] = true;
		}

		//縦
		rep(i, 9) rep(j, 9) rep(k, 9)
		{
			if (masu[j][i] == masu[k][i] && j != k) wrong[j][i] = wrong[k][i] = true;
		}

		//ブロック
		for (int i=0; i<9; i+=3)
		{
			for (int j=0; j<9; j+=3)
			{
				for (int k=i; k<i+3; k++)
				{
					for (int l=j; l<j+3; l++)
					{
						for (int m=i; m<i+3; m++)
						{
							for (int n=j; n<j+3; n++)
							{
								if (masu[k][l] == masu[m][n] && k != m && l != n)
								{
									wrong[k][l] = wrong[m][n] = true;
								}
							}
						}
					}
				}
			}
		}

		rep(i, 9)
		{
			rep(j, 9)
			{
				if (wrong[i][j]) cout << "*";
				else cout << " ";
				cout << masu[i][j];
			}
			cout << endl;
		}

		if (n != 0) cout << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<cstdio>
#include<cmath>
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
	int n;
	cin>>n;
	bool h=false;
	rep(w,n){
	if(h)cout<<endl;
		int in[9][9]={0};
		rep(j,9)rep(k,9)cin>>in[j][k];
		int out[9][9]={0};
		rep(i,9){
			rep(j,9){
				int co=0;
				rep(k,9)if(in[i][k]==j+1)co++;
				if(co>1)rep(k,9)if(in[i][k]==j+1)out[i][k]=1;
			}
		}
		rep(i,9){
			rep(j,9){
				int co=0;
				rep(k,9)if(in[k][i]==j+1)co++;
				if(co>1)rep(k,9)if(in[k][i]==j+1)out[k][i]=1;
			}
		}
		rep(i,3)rep(j,3){
			map<int,int>m;
			rep(a,3)rep(b,3)m[in[3*i+a][3*j+b]]++;
			rep(k,9)if(m[k+1]>=2)rep(a,3)rep(b,3)if(in[3*i+a][3*j+b]==k+1)out[3*i+a][3*j+b]=1;
		}
		rep(i,9){
			rep(j,9)
				if(out[i][j]==0)cout<<" "<<in[i][j];
				else cout<<"*"<<in[i][j];
			cout<<endl;
		}
		h=true;
	}
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N;
	cin >> N;
	while (N--) {
		int field[9][9];
		for (int i = 0; i < 9; ++i) {
			for (int j = 0; j < 9; ++j) {
				cin >> field[i][j];
			}
		}
		vector<vector<int>>oks(9, vector<int>(9,true));
		for (int i = 0; i < 9; ++i) {
			for (int j = 0; j < 9; ++j) {
				for (int k = 0; k < 9; ++k) {
					if (j == k)continue;
					if (field[i][j] == field[i][k])oks[i][j] = false;
				}
				for (int k = 0; k < 9; ++k) {
					if (i == k)continue;
					if (field[i][j] == field[k][j])oks[i][j] = false;
				}
				int ax = j / 3;
				int ay = i / 3;
				for (int k = ax * 3; k < ax * 3 + 3; ++k) {
					for (int l = ay * 3; l < ay * 3 + 3; ++l) {
						if (k == j&&l == i)continue;
						if (field[i][j] == field[l][k])oks[i][j] = false;
					}
				}
			}
		}
		for (int i = 0; i < 9; ++i) {
			for (int j = 0; j < 9; ++j) {
				if (oks[i][j])cout << " ";
				else cout << "*";
				cout << field[i][j];
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

C++: #include<stdio.h>
int table[9][9];
bool NG[9][9];
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
				scanf("%d",&table[i][j]);
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
				NG[i][j]=false;
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				bool ok=true;
				for(int k=0;k<9;k++){
					if(table[i][j]==table[i][k]&&j!=k)ok=false;
				}
				for(int k=0;k<9;k++){
					if(table[i][j]==table[k][j]&&i!=k)ok=false;
				}
				int seci=i/3;
				int secj=j/3;
				for(int k=0;k<3;k++){
					for(int 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)NG[i][j]=true;
			}
		}
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				printf(NG[i][j]?"*":" ");
				printf("%d",table[i][j]);
			}
			printf("\n");
		}
		if(a)printf("\n");
	}
}