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 <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n;
    cin >> n;
    rep(q, n){
        vii v; vbb b;
        rep(i, 9){
            vi r; vb l;
            rep(j, 9){
                int m; cin >> m; r.pb(m); l.pb(true);
            }
            v.pb(r); b.pb(l);
        }
        rep(i, 9){
            pair<bool, pair<int, int> > p[11];
            rep(j, 11) p[i].first = false;
            rep(j, 9){
                if(!p[v[i][j]].first){p[v[i][j]].first = true; p[v[i][j]].second = mp(i, j);}
                else {b[i][j] = false; pii x = p[v[i][j]].second; b[x.first][x.second] = false;}
            }
        }
        rep(i, 9){
            pair<bool, pair<int, int> > p[11];
            rep(j, 11) p[j].first = false;
            rep(j, 9){
                if(!p[v[j][i]].first){p[v[j][i]].first = true; p[v[j][i]].second = mp(j, i);}
                else {b[j][i] = false; pii x = p[v[j][i]].second; b[x.first][x.second] = false;}
            }
        }
        rep(i, 3)rep(j, 3){
            pair<bool, pair<int, int> > p[11];
            rep(l, 11) p[l].first = false;
            rep(k, 3)rep(l, 3){
                if(!p[v[i*3+k][j*3+l]].first){p[v[i*3+k][j*3+l]].first = true; p[v[i*3+k][j*3+l]].second = mp(i*3+k, j*3+l);}
                else {b[i*3+k][j*3+l] = false; pii x = p[v[i*3+k][j*3+l]].second; b[x.first][x.second] = false;  }
            }
        }

        rep(i, 9){
            rep(j, 9){
                cout << (b[i][j]?" ":"*") << v[i][j];
            }
            cout << endl;
        }
        if(q != n-1) cout << endl;
    }
}

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

int puzzle[9][9];
bool right(int y,int x){
  for(int i=0;i<9;i++){
    if(y!=i){
      if(puzzle[y][x]==puzzle[i][x]) return false;
    }
    if(x!=i){
      if(puzzle[y][x]==puzzle[y][i]) return false;
    }
  }

  int a=y,b=x;
  while(1){
    if(a%3==0) break;
    a--;
  }
  while(1){
    if(b%3==0) break;
    b--;
  }

  for(int i=a;i<a+3;i++){
    for(int j=b;j<b+3;j++){
      if(i!=y && j!=x){
	if(puzzle[i][j]==puzzle[y][x]){
	  return false;
	}
      }
    }
  }
  return true;
}


int main(){
  int n;
  cin>> n;
  while(n--){
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	cin>> puzzle[i][j];
      }
    }

    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	if(right(i,j)){
	  cout<< " "<< puzzle[i][j];
	}
	else {
	  cout<< '*'<< puzzle[i][j];
	}
      }
      cout<< endl;
    }
  }
}

C++: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int dy[] = {0, 0, 0, 1, 1, 1, 2, 2, 2};
int dx[] = {0, 1, 2, 0, 1, 2, 0, 1, 2};

void solve() {
  int a[9][9], wa[9][9] = {};
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> a[i][j];
    }
  }
  for (int d = 1; d < 10; d++) {
    for (int i = 0; i < 9; i++) {
      int cnt = 0;
      for (int j = 0; j < 9; j++) {
        cnt += a[i][j] == d;
      }
      if (cnt == 1) continue;
      for (int j = 0; j < 9; j++) {
        if (a[i][j] == d) wa[i][j] = 1;
      }
    }
    for (int j = 0; j < 9; j++) {
      int cnt = 0;
      for (int i = 0; i < 9; i++) {
        cnt += a[i][j] == d;
      }
      if (cnt == 1) continue;
      for (int i = 0; i < 9; i++) {
        if (a[i][j] == d) wa[i][j] = 1;
      }
    }
    for (int i = 0; i < 9; i += 3) {
      for (int j = 0; j < 9; j += 3) {
        int cnt = 0;
        for (int k = 0; k < 9; k++) {
          int ny = i + dy[k], nx = j + dx[k];
          cnt += a[ny][nx] == d;
        }
        if (cnt == 1) continue;
        for (int k = 0; k < 9; k++) {
          int ny = i + dy[k], nx = j + dx[k];
          if (a[ny][nx] == d) wa[ny][nx] = 1;
        }
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << " *"[wa[i][j]] << a[i][j];
    }
    cout << endl;
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    if (i) cout << endl;
    solve();
  }

  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;
    }
    
  }
}