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 <algorithm>
using namespace std;

const int H = 9;
const int W = 9;

int G[H][W];

bool chack(int pi, int pj) {
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      if(i == pi && j == pj) continue;
      if(i == pi || j == pj || i/3 == pi/3 && j/3 == pj/3) {
        if(G[i][j] == G[pi][pj]) return true;
      }
    }
  }
  return false;
}

int main() {
  int Tc;
  cin >> Tc;
  for(int tc = 0; tc < Tc; ++tc) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        if(cin >> G[i][j]) ; else return 0;
      }
    }
    if(tc) cout << endl;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cout << ( chack(i, j) ? '*' : ' ' );
        cout << G[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}

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(hoge,n){
    vvi v(11,vi(11,0));
    rep(i,9)rep(j,9)cin>>v[i][j];
    //rep(i,9){rep(j,9)cout<<v[i][j];cout<<endl;}
    vector<vector<bool> >flag(10,vb(10,true));
    rep(j,9){
        vb used(10,false);
        rep(i,9){
            if(used[v[i][j]]==true)
            {flag[i][j]=false;
            rep(k,9)if(v[i][j]==v[k][j])flag[k][j]=false;
            }
            else used[v[i][j]]=true;
        }
    }
    rep(i,9){
        vb used(10,false);
        rep(j,9){
            if(used[v[i][j]]==true){flag[i][j]=false;
            rep(k,9)if(v[i][j]==v[k][j])flag[k][j]=false;
            else used[v[i][j]]=true;
            }
        }
    }

      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]]==true){
                        flag[i][j]=false;
                        for(int l=h;l<h+3;l++)
                            for(int m=w;m<w+3;m++)
                                if(v[l][m]==v[i][j])flag[l][m]=false;
                        }
                        else used[v[i][j]]=true;
                    }
                }
            }
      }
    rep(i,9){
        rep(j,9){
            if(!flag[i][j])cout<<"*";
            else cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
        }
    }
}

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

int main() {
	int N;
	int map[9][9];
	bool flg[9][9];
	cin >> N;
	while (N--) {
		memset(flg, 0, sizeof(flg));
		for (int i=0; i<9; i++)
		for (int j=0; j<9; j++)
			cin >> map[i][j];

		int cnt[3][9];

		for (int i=0; i<9; i++) {
			memset(cnt, 0, sizeof(cnt));
			for (int j=0; j<9; j++) {
				cnt[0][map[i][j]-1]++;
				cnt[1][map[j][i]-1]++;
				cnt[2][map[3*(i/3)+j/3][3*(i%3)+j%3]-1]++;
			}
			queue<int> q;
			for (int j=0; j<9; j++) {
				for (int k=0; k<3; k++) {
					if (cnt[k][j] > 1) q.push(k);
				}
				while (!q.empty()) {
					int p = q.front(); q.pop();
					for (int k=0; k<9; k++) {
						if (p==0&&map[i][k]==j+1) flg[i][k] = true;
						if (p==1&&map[k][i]==j+1) flg[k][i] = true;
						if (p==2&&map[3*(i/3)+k/3][3*(i%3)+k%3]==j+1) flg[3*(i/3)+k/3][3*(i%3)+k%3] = true;
					}
				}
			}
		}

		for (int i=0; i<9; i++) {
			for (int j=0; j<9; j++)
				cout << (flg[i][j] ? '*':' ') << map[i][j];
			cout << endl;
		}

		if (N) 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;
    }
    
  }
}

C++: #include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
bool ok[9][9] = {};
void check(int *a, int x, bool f) {
	int c[9] = {};
	rep(i,9) c[a[i]-1]++;
	rep(i,9) {
		if(c[a[i]-1] != 1) {
			if(f) ok[x][i] = 1;
			else ok[i][x] = 1;
		}
	}
}
int main() {
	int n;
	cin >> n;
	bool p = 0;
	while(n--) {
		if(p) cout << endl;
		p = 1;
		int b[9][9];
		rep(i,9) {
			rep(j,9) {
				ok[i][j] = 0;
				cin >> b[i][j];
			}
		}
		rep(i,9) {
			int a[9];
			rep(j,9) {
				a[j] = b[i][j];
			}
			check(a,i,1);	
		}
		rep(i,9) {
			int a[9];
			rep(j,9) {
				a[j] = b[j][i];
			}
			check(a,i,0);	
		}
		rep(w,9) {
			if(w%3!=0) continue;
			rep(h,9) {
				if(h%3!=0) continue;
				int c[9]={};
				rep(i,3) {
					rep(j,3) {
						c[b[w+i][h+j]-1]++;
					}
				}
				rep(i,3) {
					rep(j,3) {
						if(c[b[w+i][h+j]-1] != 1) ok[w+i][h+j] = 1;
					}
				}
			}
		}
		rep(i,9) {
			string ret;
			rep(j,9) {
				if(ok[i][j]) ret += '*';
				else ret += ' ';
				ret += (char)(b[i][j]+'0');
			}
			cout << ret << endl;
		}
	}
	return 0;
}