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++: #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

#define rep(i, n) for(int i = 0; i < n; i++)

int nums[9][9];
bool ok[9][9];

bool check(int y, int x){
	int num = nums[y][x];
	rep(i, 9){
		if(i == y) continue;
		if(nums[i][x] == num) return false;
	}
	rep(i, 9){
		if(i == x) continue;
		if(nums[y][i] == num) return false;
	}
	int by = y / 3;
	int bx = x / 3;
	rep(i, 3){
		rep(j, 3){
			if(by * 3 + i == y && bx * 3 + j == x) continue;
			if(nums[by*3+i][bx*3+j] == num) return false;
		}
	}
	return true;
}

int main(){
	int n;
	cin >> n;
	rep(i, n){
		if(i != 0) cout << endl;
		memset(ok, true, sizeof(ok));
		rep(j, 9)rep(k, 9) cin >> nums[j][k];
		rep(j, 9)rep(k, 9) ok[j][k] = check(j, k);
		rep(j, 9){
			rep(k, 9){
				if(!ok[j][k]) cout << '*';
				else cout << ' ';
				cout << nums[j][k];
			}
			cout << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());

int a[]={0,1,2};
int main(){
	int n;
	cin>>n;
	rep(u,n){
		vector<vint> vv;
		vector<vint> ans;
		initvv(ans,9,9);
		initvv(vv,9,9);
		rep(i,9){
			rep(j,9){
				cin>>vv[i][j];
				ans[i][j]=0;
			}
		}
		rep(i,9){
			vint t(10,0);
			rep(j,9){
				t[vv[i][j]]++;
			}
			rep(j,9){
				if(t[vv[i][j]]>1){
					ans[i][j]=1;
				}
			}
		}
		rep(i,9){
			vint t(10,0);
			rep(j,9){
				t[vv[j][i]]++;
			}
			rep(j,9){
				if(t[vv[j][i]]>1){
					ans[j][i]=1;
				}
			}
		}
		rep(i,3){
			rep(j,3){
				int x=i*3,y=j*3;
				vint t(10,0);
				rep(k,3){
					rep(l,3){
						t[vv[k+x][l+y]]++;
					}
				}
				rep(k,3){
					rep(l,3){
						if(t[vv[k+x][l+y]]>1){
							ans[k+x][l+y]=1;
						}
					}
				}
			}

		}
		rep(i,9){
			rep(j,9){
				if(ans[i][j]==1){
					cout<<"*";
				}
				else cout<<" ";
				cout<<vv[i][j];
			}
			cout<<endl;
		}
		if(u!=n-1) 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;
  bool first = true;
  while(N--){
    if(first) first = false;
    else cout << endl;
    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;
}