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;

int main(void){
  int n ;
  cin>>n;
  while(n--){
    vector<vector<char> > in(9,vector<char>(9));
    vector<vector<bool> > ans(9,vector<bool>(9,false));
    vector<vector<int> > usedx(9,vector<int>(9,-1));
    vector<vector<int> > usedy(9,vector<int>(9,-1));
    vector<vector<int> > usedz(9,vector<int>(9,-1));

    for(int i = 0 ; i < 9 ; i ++){
      for(int j = 0 ; j < 9 ; j ++){

	cin>>in[i][j];
	in[i][j] = in[i][j] - '1';
	
	if(usedx[i][in[i][j]] == -1){
	  usedx[i][in[i][j]] = j;
	}else{
	  ans[i][j] = true;
	  ans[i][usedx[i][in[i][j]]] = true ;
	}

	if(usedy[in[i][j]][j] == -1){
	  usedy[in[i][j]][j] = i;
	}else{
	  ans[i][j] = true;
	  ans[usedy[in[i][j]][j]][j] = true;
	}
	
	//cout<<(int)in[i][j]<<" "<<i<<" "<<j<<" "<<i/3*3+j/3<<endl;
	if(usedz[i/3*3+j/3][in[i][j]] == -1){
	  usedz[i/3*3+j/3][in[i][j]] = i*10+j;
	}else{
	  ans[i][j] = true;
	  ans[usedz[i/3*3+j/3][in[i][j]]/10][usedz[i/3*3+j/3][in[i][j]]%10] = true;
	}
      }
    }
    
    for(int i = 0 ; i < 9 ; i ++){
      for(int j = 0 ; j < 9 ; j ++){
	if(ans[i][j])cout<<"*";
	else cout<<" ";
	cout<<(int)in[i][j]+1<<" ";
      }
      cout<<endl;
    }
    cout<<endl;
  }
}

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

int map[9][9] , f[9][9] = {} ;

int main(){
	
	int n ;
	cin >> n ;
	for( int m=1 ; m<=n ; m++ ){
		
		for( int i=0 ; i<9 ; i++ ){
			for( int j=0 ; j<9 ; j++ ){
				cin >> map[i][j] ;
			}
		}
		
		for( int i=0 ; i<9 ; i++ ){
			for( int j=0 ; j<9 ; j++ ){
				for( int k=0 ; k<9 ; k++ ){
					if( j!=k ){
						if( map[i][j] == map[i][k] ) f[i][j] = m ;
						if( map[j][i] == map[k][i] ) f[j][i] = m ;
					}
					if( i != i/3*3+k/3 && j != j/3*3+k%3 ){
						if( map[i][j] == map[i/3*3+k/3][j/3*3+k%3] ){
							f[i][j] = m ;
						}
					}
				}
			}
		}
		
		for( int i=0 ; i<9 ; i++ ){
			for( int j=0 ; j<9 ; j++ ){
				if( f[i][j] == m ) cout << '*' ;
				else  cout << ' ' ;
				
				cout << map[i][j] ;
			}
			cout << endl ;
		}
		if( m!=n )cout << endl ;
	}
	
return 0 ;
}