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<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 ;
		}
		cout << endl ;
	}
	
return 0 ;
}

C++: #include<iostream>
#include<set>
#include<cstring>

void input(int mat[9][9]);
void checkrow(const int mat[9][9],std::set<std::pair<int,int> >& wrong,int r);
void checkcolumn(const int mat[9][9],std::set<std::pair<int,int> >& wrong,int c);
void checksquare(const int mat[9][9],std::set<std::pair<int,int> >& wrong,int n);
void output(const int mat[9][9],const std::set<std::pair<int,int> >& wrong);

int main()
{
	int n;
	std::cin>>n;
	for(int k=0;k<n;k++)
	{
		int mat[9][9];
		std::set<std::pair<int,int> > wrong;
		input(mat);
		
		for(int i=0;i<9;i++)
		{
//			checkrow(mat,wrong,i);
//			checkcolumn(mat,wrong,i);
			checksquare(mat,wrong,i);
		}
		if(k>0)std::cout<<std::endl;
		output(mat,wrong);
	}
	return 0;
}

void input(int mat[9][9])
{
	for(int i=0;i<9;i++)
	{
		for(int j=0;j<9;j++)
		{
			std::cin>>mat[i][j];
		}
	}
}

void checkrow(const int mat[9][9],std::set<std::pair<int,int> >& wrong,int r)
{
	int already[9];
	memset(already,-1,sizeof(already));
	for(int j=0;j<9;j++)
	{
		if(already[mat[r][j]-1]!=-1)
		{
			wrong.insert(std::pair<int,int>(r,j));
			wrong.insert(std::pair<int,int>(r,already[mat[r][j]-1]));
		}
		already[mat[r][j]-1]=j;
	}
}

void checkcolumn(const int mat[9][9],std::set<std::pair<int,int> >& wrong,int c)
{
	int already[9];
	memset(already,-1,sizeof(already));
	for(int i=0;i<9;i++)
	{
		if(already[mat[i][c]-1]!=-1)
		{
			wrong.insert(std::pair<int,int>(i,c));
			wrong.insert(std::pair<int,int>(already[mat[i][c]-1],c));
		}
		already[mat[i][c]-1]=i;
	}
}

void checksquare(const int mat[9][9],std::set<std::pair<int,int> >& wrong,int n)
{
	int already[9];
	memset(already,-1,sizeof(already));
	for(int i=n/3*3;i<n/3*3+3;i++)
	{
		for(int j=n%3*3;j<n%3*3+3;j++)
		{
			if(already[mat[i][j]-1]!=-1)
			{
				wrong.insert(std::pair<int,int>(i,j));
				wrong.insert(std::pair<int,int>(already[mat[i][j]-1],j));
			}
			already[mat[i][j]-1]=i;
		}
	}
}

void output(const int mat[9][9],const std::set<std::pair<int,int> >& wrong)
{
	for(int i=0;i<9;i++)
	{
		for(int j=0;j<9;j++)
		{
			if(wrong.find(std::pair<int,int>(i,j))==wrong.end())
			{
				std::cout<<' ';
			}
			else
			{
				std::cout<<'*';
			}
			std::cout<<mat[i][j];
		}
		std::cout<<std::endl;
	}
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int n; cin>>n;
    rep(p,n){
    vector<vector<bool> >flag(10,vb(10,true));
    vvi v(10,vi(10,0));
    rep(i,9)rep(j,9)cin>>v[i][j];
    for(int i=0;i<9;i++){
        vb used(10,false);
        for(int j=0; j<9;j++){
            if(!used[v[i][j]]){used[v[i][j]]=true;}
            else {
                flag[i][j]=false;
                rep(k,9)if(v[i][k]==v[i][j])flag[i][k]=false;
            }
        }
    }
    for(int j=0;j<9;j++){
        vb used(10,false);
        for(int i=0; i<9;i++){
            if(!used[v[i][j]]){used[v[i][j]]=true;}
            else {
                flag[i][j]=false;
                rep(k,9)if(v[k][j]==v[i][j])flag[k][j]=false;
            }
        }
    }
   
    for(int h=0; h<=8;h+=3){
        for(int w=0; w<=8;w+=3){
            vb used(10,false);
            for(int i=h; i<h+3;i++){
                for(int j=w; j<w+3;j++){
                    if(!used[v[i][j]])used[v[i][j]]=true;
                    else for(int k=h; k<h+3;k++){
                            for(int m=w; m<w+3;m++){
                                if(v[k][m]==v[i][j])flag[k][m]=false;
                        }
                    }
                }
            }
        }
    }
    rep(i,9){
        rep(j,9){
            if(flag[i][j])cout<<" ";
            else cout<<"*";
            cout<<v[i][j];
        }
       if(p!=n-1) cout<<endl;
    }
}
};

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

int main(){
  bool error[10][10];
  int puzzle[10][10];
  
  int T;
  cin >> T;
  while(T--){
    for(int i = 0 ; i < 9 ; i++){
      for(int j = 0 ; j < 9 ; j++){
	cin >> puzzle[i][j];
      }
    }
    
    memset(error, 0, sizeof(error));
    int check1[10];
    int check2[10];
    
    for(int i = 0 ; i < 9 ; i++){
      memset(check1, 0, sizeof(check1));
      memset(check2, 0, sizeof(check2));
      for(int j = 0 ; j < 9 ; j++){
	check1[puzzle[i][j]]++;
	check2[puzzle[j][i]]++;
	if(check1[puzzle[i][j]] == 2){
	  error[i][j] = 1;
	  for(int k = 0 ; k < 9 ; k++){
	    if(puzzle[i][k] == puzzle[i][j]) error[i][k] = 1;
	  }
	}
	  
	if(check2[puzzle[j][i]] == 2){
	  error[j][i] = 1;
	  for(int k = 0 ; k < 9 ; k++){
	    if(puzzle[k][i] == puzzle[j][i]) error[k][i] = 1;
	  }
	}
	
      }
    }
    
    for(int i = 0 ; i < 9 ; i++){
      for(int j = 0 ; j < 9 ; j++){
	cout << ((error[i][j]) ? '*' : ' ') << puzzle[i][j];
      }
      cout << endl;
    }
    if(T)cout << endl;
  }
  return 0;
}