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<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;
                        }
                    }
                }
            }
        }
    }
        cout<<endl;
    rep(i,9){
        rep(j,9){
            if(flag[i][j])cout<<" ";
            else cout<<"*";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
};

C++: #include <bits/stdc++.h>
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  while(N--){
    int f[9][9];
    for(int i = 0; i < 9; i++){
      for(int j = 0; j < 9; j++){
        cin >> f[i][j];
        f[i][j]--;
      }
    }
    vector< vector<bool> > wrong(9, vector<bool>(9, false));
    vector<bool> used(9, false);
    //columm
    for(int i = 0; i < 9; i++){
      used = vector<bool>(9, false);
      list<int> t;
      for(int j = 0; j < 9; j++){
        if(used[ f[i][j] ] == true){
          t.push_back(f[i][j]);
        }else{
          used[ f[i][j] ] = true;
        }
      }
      for(int j = 0; j < 9; j++){
        for(list<int>::iterator it = t.begin(); it != t.end(); it++){
          if(f[i][j] == *it){
            wrong[i][j] = true;
          }
        }
      }
    }

    //row
    for(int j = 0; j < 9; j++){
      used = vector<bool>(9, false);
      list<int> t;
      for(int i = 0; i < 9; i++){
        if(used[ f[i][j] ] == true){
          t.push_back(f[i][j]);
        }else{
          used[ f[i][j] ] = true;
        }
      }
      for(int i = 0; i < 9; i++){
        for(list<int>::iterator it = t.begin(); it != t.end(); it++){
          if(f[i][j] == *it){
            wrong[i][j] = true;
          }
        }
      }
    }

    //sp area
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){

        used = vector<bool>(9, false);
        list<int> t;
        for(int k = 0; k < 3; k++){
          for(int l = 0; l < 3; l++){
            if(used[ f[i*3+k][j*3+l] ] == true){
              t.push_back(f[i*3+k][j*3+l]);
            }else{
              used[ f[i*3+k][j*3+l] ] = true;
            }
          }
        }
        for(int k = 0; k < 3; k++){
          for(int l = 0; l < 3; l++){
            for(list<int>::iterator it = t.begin(); it != t.end(); it++){
              if(f[i*3+k][j*3+l] == *it){
                wrong[i*3+k][j*3+l] = true;
              }
            }
          }
        }
      }
    }

    for(int i = 0; i < 9; i++){
      for(int j = 0; j < 9; j++){
        if(wrong[i][j]) cout << "*";
        else cout << " ";
        cout << f[i][j]+1;
      }
      cout << endl;
    }
  }

  return 0;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
bool maze[9][9];
void tate(vector<string> s){
  /*
  cout<<"tate"<<endl;
  rep(i,9){
    rep(j,9)
      cout<<s[j][i]<<" ";
    cout<<endl;
  }
  //*/
  rep(i,9){
    //cout<<i<<endl;
    int used[9] = {0};
    rep(j,9){
      used[s[j][i]-'1']++;
    }
    rep(j,9){
      if(used[j] > 1){
	rep(k,9){
	  if(s[k][i] == j + '1')maze[k][i] = false;
	}
      }
    }
  }  
}

void yoko(vector<string> s){
  rep(i,9){
    //cout<<i<<endl;
    int used[9] = {0};
    rep(j,9){
      used[s[i][j]-'1']++;
    }
    rep(j,9){
      if(used[j] > 1){
	rep(k,9){
	  if(s[i][k] == j + '1')maze[i][k] = false;
	}
      }
    }
  }    
}

void masu(vector<string> s){
  rep(i,3){
    rep(j,3){
      int used[9] = {0};
      rep(k,3){
	rep(l,3){
	  used[s[i*3+k][j*3+l] - '1'] ++;
	}
      }
      
      rep(k,3){
	rep(l,3){
	  int x = i * 3 + k, y =  j * 3 + l;
	  
	  if(used[s[x][y] -'1'] >1)
	  if(s[x][y] == j + '1')maze[x][y] = false;
	}
      }
      
    }
  }
}

int main(void){
  int n;
  cin>>n;
  while(n--){
    vector<string> s;
    rep(i,9){
      string str;
      rep(j,9){
	maze[i][j] = true;
	string ss;
	cin>>ss;
	str += ss;
      }
      s.push_back(str);
    }
    cout<<endl;
    
    tate(s);
    yoko(s);
    masu(s);
    rep(i,9){
      rep(j,9){
	if(maze[i][j])cout<<" ";
	else cout<<"*";
	cout<<s[i][j];
      }
      cout<<endl;
    }
    
  }
}