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<cstdio>
#include<map>
using namespace std;
char _[9][9];
char cmap[9][9];

void rect_search(int x,int y){
  map<char,int> used;
  for(int i=y;i<y+3;i++){
    for(int j=x;j<x+3;j++){
      used[cmap[i][j]]++;
    }
  }

  map<char,int>::iterator it = used.begin();
  while(it != used.end() ){
    if((*it).second > 1){
      for(int i=y;i<y+3;i++){
	for(int j=x;j<x+3;j++){
	  if(cmap[i][j] == (*it).first){
	    _[i][j] = '*';
	  } 
	}
      }    
    }
    it++;
  }
}

void corss_search(int x,int y){
  map<char,int> used;
  for(int i=0;i<9;i++){
    used[cmap[i][x]]++;
  }
  map<char,int>::iterator it = used.begin();
  while(it != used.end()){
    if((*it).second > 1){
      for(int i=0;i<9;i++){
	if(cmap[i][x] == (*it).first)_[i][x] = '*';
      }
    }
    it++;
  }
  used.clear();
  for(int i=0;i<9;i++){
    used[cmap[y][i]]++;
  }
  it = used.begin();
  while(it != used.end()){
    if((*it).second > 1){
      for(int i=0;i<9;i++){
	if(cmap[y][i] == (*it).first)_[y][i] = '*';
      }
    }
    it++;
  }

}


int main(){
  int n;

  scanf("%d",&n);
  while(n-- > 0){
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	_[i][j] = ' ';
      }
    }
    for(int i=0;i<9;i++){
      cin >> cmap[i][0] >> cmap[i][1] >> cmap[i][2] >> cmap[i][3] >> cmap[i][4] >> cmap[i][5] >> cmap[i][6] >> cmap[i][7] >> cmap[i][8];
    }
   
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	corss_search(j,i);
      }
    }

    for(int i=0;i<9;i+=3){
      for(int j=0;j<9;j+=3)rect_search(j,i);
    }


    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	printf("%c%c",_[i][j],cmap[i][j]);
      }
      printf("\n");
    }
    if(n-1 >= 0)printf("\n");


  }
  return 0;
}

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

const int COL_SIZE = 9;
const int ROW_SIZE = 9;

void inputBoard( int board[][ COL_SIZE ] )
{
	for( int i = 0; i < ROW_SIZE; ++i ){
		for( int j = 0; j < COL_SIZE; ++j ){
			cin >> board[ i ][ j ];
		}
	}
}

void outputBoard( int board[][ COL_SIZE ], bool check[][ COL_SIZE ] )
{
	for( int i = 0; i < ROW_SIZE; ++i ){
		for( int j = 0; j < COL_SIZE; ++j ){
			cout << ( check[ i ][ j ] ? '*' : ' ' ) << board[ i ][ j ];
		}
		cout << endl;
	}
}

enum{
	COL = 0,
	ROW,
	BLOCK
};

bool investigate( int board[][ COL_SIZE ], bool check[][ COL_SIZE ] )
{
	for( int i = 0; i < ROW_SIZE; ++i ){
		int usedNumber[ 3 ][ 10 ];
		memset( usedNumber, 0, sizeof(usedNumber) );
		for( int j = 0; j < COL_SIZE; ++j ){
			usedNumber[ COL ][ board[ i ][ j ] ]++;
			usedNumber[ ROW ][ board[ j ][ i ] ]++;
			usedNumber[ BLOCK ][ board[ ( i / 3 ) * 3 + j / 3 ][ ( i % 3 ) * 3 + j % 3 ] ]++;
		}
		for( int j = 0; j < COL_SIZE; ++j ){
			if( usedNumber[ COL ][ board[ i ][ j ] ] > 1 ){
				check[ i ][ j ] = true;
			}
			if( usedNumber[ ROW ][ board[ j ][ i ] ] > 1 ){
				check[ j ][ i ] = true;
			}
			int y = ( i / 3 ) * 3 + j / 3;
			int x = ( i % 3 ) * 3 + j % 3;
			if( usedNumber[ BLOCK][ board[ y ][ x ] ] > 1 ){
				check[ y ][ x ] = true;
			}
		}
	}
	return false;
}

int main()
{
	int n;
	cin >> n;
	for( int i = 0; i < n; ++i ){
		int board[ ROW_SIZE ][ COL_SIZE ];
		bool check[ ROW_SIZE ][ COL_SIZE ];
		memset( check, 0, sizeof(check) );
		inputBoard( board );
		investigate( board, check );
		if( i != 0 ){
			cout << endl;
		}
		outputBoard( board, check );
	}
	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][k][stage[j][k]]++;
				 cnt[2][(j / 3) * 3 + k / 3][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 <bits/stdc++.h>
using namespace std;

int n;
int a[9][9];
bool ok[9][9];

int main() {
    cin >> n;
    for (int iter = 0; iter < n; ++iter) {
        for (int i = 0; i < 9; ++i) for (int j = 0; j < 9; ++j) {
            cin >> a[i][j];
            ok[i][j] = true;
        }
        for (int i1 = 0; i1 < 3; ++i1) for (int j1 = 0; j1 < 3; ++j1) {
            for (int i2 = 0; i2 < 3; ++i2) for (int j2 = 0; j2 < 3; ++j2) {
                int i = i1 * 3 + i2, j = j1 * 3 + j2;
                int num = a[i][j];
                
                // the mass
                for (int i3 = 0; i3 < 3; ++i3) for (int j3 = 0; j3 < 3; ++j3) {
                    int I = i1 * 3 + i3, J = j1 * 3 + j3;
                    if (I == i && J == j) continue;
                    if (a[I][J] == num) {
                        ok[i][j] = false;
                    }
                }
                
                // the row
                for (int J = 0; J < 9; ++J) {
                    if (J == j) continue;
                    if (a[i][J] == num) {
                        ok[i][j] = false;
                    }
                }
                
                // the col
                for (int I = 0; I < 9; ++I) {
                    if (I == i) continue;
                    if (a[I][j] == num) {
                        ok[i][j] = false;
                    }
                }
            }
        }
        
        for (int i = 0; i < 9; ++i) {
            for (int j = 0; j < 9; ++j) {
                cout << (ok[i][j] ? ' ' : '*');
                cout << a[i][j];
            }
            cout << endl;
        }
        if (iter != n-1) cout << endl;
    }
}

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

int main(){

	int n, l[10][10], a[10][10];
	int m[10][10] = {0};

	cin >> n;
	
	for(int i=0; i<n; i++){
		for(int j=1; j<10; j++){
			for(int k=1; k<10; k++){
				l[j][k] = 0;
				a[j][k] = 0;
			}
		}
//		fill(l, l+9*9, 0);
//		fill(a, a+9*9, 0);

		for(int j=1; j<10; j++){
			for(int k=1; k<10; k++){
				scanf("%d", &m[j][k]);
				l[j][m[j][k]]++;
				a[k][m[j][k]]++;
			}
		}

		for(int j=1; j<10; j++){
			for(int k=1; k<10; k++){
				if(l[j][m[j][k]] == 1 && a[k][m[j][k]] == 1){
					cout << " ";
				}
				else{
					cout << "*";
				}
				cout << m[j][k];
			}
			cout << endl;
		}
		if(i!=n-1) cout << endl;
	}

	return 0;

}