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>
using namespace std;
int I;
int t[9][9];
bool flg[9][9];
int main(){
  cin>>I;
  while(I--){
    for(int i=0;i<9;i++)for(int j=0;j<9;j++){cin>>t[i][j];flg[i][j]=false;}

    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(t[i][j]==t[i][k]){
	    flg[i][j]=true;
	  }
	}//k
      }//j
    }//i

    for(int j=0;j<9;j++){      
      for(int i=0;i<9;i++){
	for(int k=0;k<9;k++){
	  if(i==k)continue;
	  if(t[i][j]==t[k][j]){
	    flg[i][j]=true;
	  }
	}//k
      }//i
    }//j

    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(m==k&&n==l)continue;
		if(t[k][l]==t[m][n])flg[k][l]=true;
	      }//n
	    }//m

	  }//l
	}//k

      }//j
    }//i


    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	cout<<(flg[i][j]?'*':' ')<<t[i][j];
      }
      cout<<endl;
    }
    if(I>0)cout<<endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	cin >> n;
	
	while(n--)
	{
		vector<vint> table(9, vint(9));
		
		rep(y, 9) rep(x, 9)
		{
			cin >> table[y][x];
			table[y][x]--;
		}
		
		vector<bitset<9> > flags(9);
		
		// ツ行
		rep(y, 9) 
		{
			vint v(9, 0);
			rep(x, 9)
			{
				v[table[y][x]]++;
			}
			
			rep(x, 9)
			{
				flags[y][x] = 1 < v[table[y][x]];
			}
		}
		
		// ツ療ア
		rep(x, 9) 
		{
			vint v(9, 0);
			rep(y, 9)
			{
				v[table[y][x]]++;
			}
			
			rep(y, 9)
			{
				flags[y][x] = flags[y][x] || 1 < v[table[y][x]];
			}
		}
		
		
		// square
		rep(y, 3) rep(x, 3) 
		{
			vint v(9, 0);
			rep(yy, 3) rep(xx, 3)
			{
				v[table[y * 3 + yy][x * 3 + xx]]++;
			}
			
			rep(yy, 3) rep(xx, 3)
			{
				flags[y * 3 + yy][x * 3 + xx] = flags[y * 3 + yy][x * 3 + xx] || 1 < v[table[y * 3 + yy][x * 3 + xx]];
			}
		}
		
		
		// print
		rep(y, 9) rep(x, 9)
			cout << (flags[y][x] ? "*" : " ") << table[y][x] + 1 << (x == 8 && !(y == 8 && !n) ? "\n" : "");
			
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

const int MAXW = 9, MAXH = 9;

int tile[MAXW][MAXH];
bool e[MAXW][MAXH];
int c[10];
int dx[] = {0, 3, 6};
int dy[] = {0,3, 6};

int main()
{
    int n;
    cin >> n;
    rep(k,n)
    {
        if(k > 0) cout << endl;
        memset(c, 0, sizeof(c));
        memset(e, false, sizeof(e));
        rep(j,9)rep(i,9) cin >> tile[i][j];

        rep(i,9)
        {
            memset(c, 0, sizeof(c));
            rep(j,9) c[tile[j][i] ] ++;
            rep(j,9)if(c[tile[j][i] ] > 1) e[j][i] = true;

            //vartical
            memset(c, 0, sizeof(c));
            rep(j,9) c[ tile[i][j] ]++;
            rep(j,9) if(c[tile[i][j]] > 1) e[i][j] = true;
        }

        rep(t,3)rep(s,3)
        {
            memset(c, 0, sizeof(c));
            rep(i,3)rep(j,3) c[tile[i + dx[s]][j + dy[t]]]++;
            rep(i,3)rep(j,3)if(c[tile[i + dx[s]][j + dy[t]]] > 1) e[i + dx[s]][j + dy[t]] = true;
        }

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

    }
    

    return 0;
}

C++: #include <iostream>

using namespace std;

 int main(void) {


	 int n;
	 int stage[9][9];
	 int cnt[3][9][10];

	 cin >> n;

	 for (int i = 0; i < n; i++){

		 for (int j = 0; j < 9; j++){
			 for (int k = 0; k < 9; k++){
				 cin >> stage[j][k];
			 }
		 }

		 for (int j = 0; j < 3; j++){
			 for (int k = 0; k < 9; k++){
				 for (int l = 0; l < 10; l++){
					 cnt[j][k][l] = 0;
				 }
			 }
		 }

		 for (int j = 0; j < 9; j++){
			 for (int k = 0; k < 9; k++){
				 cnt[0][j][stage[j][k]]++;
				 cnt[1][j][stage[k][j]]++;
				 cnt[2][j][stage[k / 3 + (j / 3) * 3][k % 3 + (j % 3) * 3]]++;
			 }
		 }

		 for (int j = 0; j < 9; j++){
			 for (int k = 0; k < 9; k++){
				 if (cnt[0][j][stage[j][k]] <= 1 && cnt[1][k][stage[j][k]] <= 1 && cnt[2][(j / 3) * 3 + k / 3][stage[k / 3 + (j / 3) * 3][k % 3 + (j % 3) * 3]] <= 1) cout << " " << stage[j][k];
				 else cout << "*" << stage[j][k];
			 }
			 cout << endl;
		 }

	 }

	 return 0;
	
}

C++: #include <iostream>
#include <vector>
using namespace std;

int main(){
	int n;
	cin >> n;
	// input
	for( int t = 0; t < n; t++ ){
		int puzzle[9][9];
		int row[9][9] = {{0}}, col[9][9] = {{0}}, rect[9][9] = {{0}};
		for( int i = 0; i < 9; i++ ){
			for( int j = 0; j < 9; j++ ){
				cin >> puzzle[i][j];
				if( row[i][puzzle[i][j]-1] == 1 ) row[i][puzzle[i][j]-1] = -1;
				else row[i][puzzle[i][j]-1] = 1;
				if( col[j][puzzle[i][j]-1] == 1 ) col[j][puzzle[i][j]-1] = -1;
				else col[j][puzzle[i][j]-1] = 1;
				if( rect[i/3*3+j/3][puzzle[i][j]-1] == 1 ) rect[i/3*3+j/3][puzzle[i][j]-1] = -1;
				else rect[i/3*3+j/3][puzzle[i][j]-1] = 1;
			}
		}

		// output
		if( t != 0 ) cout << endl;
		for( int i = 0; i < 9; i++ ){
			for( int j = 0; j < 9; j++ ){
				if( row[i][puzzle[i][j]-1] == -1 || col[j][puzzle[i][j]-1] == -1 || rect[i/3*3+j/3][puzzle[i][j]-1] == -1 ) cout << "*";
				else cout << " ";
				cout << puzzle[i][j];
			}
			cout << endl;
		}
	}
}