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<iostream>
#include<string>
#include<memory.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int ii = 0; ii < n; ii++){
		int p[10][10];
		string s[10];
		int cnt[10];
		for (int i = 0; i < 9; i++){
			s[i] = "          ";
		}
		int a;
		for (int i = 0; i < 9; i++){
			for (int i2 = 0; i2 < 9; i2++){
				cin >> p[i][i2];
			}
		}
		memset(cnt, 0, sizeof(cnt));
		for (int i = 0; i < 9; i++){
			for (int i2 = 0; i2 < 9; i2++){
				cnt[p[i][i2]]++;
			}
			for (int i3 = 0; i3 < 9; i3++){
				if (cnt[i3] > 1){
					for (int i4 = 0; i4 < 9; i4++){
						if (p[i][i4] == i3){
							s[i][i4] = '*';
						}
					}
				}
			}memset(cnt, 0, sizeof(cnt));
		}

		for (int i = 0; i < 9; i++){
			for (int i2 = 0; i2 < 9; i2++){
				cnt[p[i2][i]]++;
			}
			for (int i3 = 0; i3 < 9; i3++){
				if (cnt[i3] > 1){
					for (int i4 = 0; i4 < 9; i4++){
						if (p[i4][i] == i3){
							s[i4][i] = '*';
						}
					}
				}
			}memset(cnt, 0, sizeof(cnt));
		}
		int y, x;
		y = 0; x = 0;

		for (int i = 0; i < 3; i++){
			for (int i2 = 0; i2 < 3; i2++){
				cnt[p[i][i2]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 0; i < 3; i++){
					for (int i2 = 0; i2 < 3; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 0; i < 3; i++){
			for (int i2 = 3; i2 < 6; i2++){
				cnt[p[i][i2]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 0; i < 3; i++){
					for (int i2 = 3; i2 < 6; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 0; i < 3; i++){
			for (int i2 = 6; i2 < 9; i2++){
				cnt[p[i][i2]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 0; i < 3; i++){
					for (int i2 = 6; i2 < 9; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 3; i < 6; i++){
			for (int i2 = 0; i2 < 3; i2++){
				cnt[p[i][i2]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 3; i < 6; i++){
					for (int i2 = 0; i2 < 3; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 3; i < 6; i++){
			for (int i2 = 3; i2 < 6; i2++){
				cnt[p[i][i2]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 3; i < 6; i++){
					for (int i2 = 3; i2 < 6; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 3; i < 6; i++){
			for (int i2 = 6; i2 < 9; i2++){
				cnt[p[i][i2]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 3; i < 6; i++){
					for (int i2 = 6; i2 < 9; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 6; i < 9; i++){
			for (int i2 = 0; i2 < 3; i2++){
				cnt[p[i][i2]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 6; i < 9; i++){
					for (int i2 = 0; i2 < 3; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 6; i < 9; i++){
			for (int i2 = 3; i2 < 6; i2++){
				cnt[p[i][i2]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 6; i < 9; i++){
					for (int i2 = 3; i2 < 6; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 6; i < 9; i++){
			for (int i2 = 6; i2 < 9; i2++){
				cnt[p[i][i2]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 6; i < 9; i++){
					for (int i2 = 6; i2 < 9; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 0; i < 9; i++){
			for (int i2 = 0; i2 < 9; i2++){
				cout << s[i][i2] << p[i][i2];
			}cout << 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(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++){
                    used[v[i][j]]=true;
                }
            }
            for(int i=h;i<h+3;i++)
                for(int j=w;j<w;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;
    }
    }
    
}