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 {
		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()
		}
		n--
	}
}

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

int main(){
	int dataset;
	cin >> dataset;
	bool f = true;
	while(dataset--){
		if(!f) cout << endl;

		vector<vi> v(9, vi(9, 0));
		vector<vi> ng = v;
		rep(i, 9) rep(j, 9) cin >> v[i][j];

		rep(i, 9){
			vi cnt1(10, 0), cnt2(10, 0), cnt3(10, 0);
			int x = i%3*3;
			int y = i/3*3;
			rep(j, 9){
				cnt1[v[i][j]]++;
				cnt2[v[j][i]]++;
				cnt3[v[y+j/3][x+j%3]]++;
			}
			rep(j, 9){
				if((cnt1[v[i][j]] >= 2)) ng[i][j] = 1;
				if(cnt2[v[j][i]] >= 2) ng[j][i] = 1;
				if((cnt3[v[y+j/3][x+j%3]] >= 2)) ng[y+j/3][x+j%3] = 1;
			}
		}

		rep(i, 9){
			rep(j, 9){
				cout << (ng[i][j]?'*':' ') << v[i][j];
			}
			cout << endl;
		}

		f = false;
	}


	return 0;
}

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

char p[9][9],m[9][9];

void vertical(int ti,int tj){
	for(int i=ti+1;i<9;i++)
		if(p[ti][tj] == p[i][tj])
			m[ti][tj] = m[i][tj] = '*';
}

void horizontal(int ti,int tj){
	for(int j=tj+1;j<9;j++)
		if(p[ti][tj] == p[ti][j])
			m[ti][tj] = m[ti][j] = '*';
}

void square(int ti,int tj){
	for(int k=(ti%3)*3+tj%3+1;k<9;k++){
		int i=ti/3*3+k/3, j=tj/3*3+k%3;
		if(p[ti][tj] == p[i][j])
			m[ti][tj] = m[i][j] = '*';
	}
}

int main(void){
	int i,j,n,set;

	cin>>n;
	for(set=0;n--;set++){
		if(set!=0) cout<<endl;
		for(i=0;i<9;i++){
			for(j=0;j<9;j++){
				cin>>p[i][j];
				m[i][j] = ' ';
			}
		}

		for(i=0;i<9;i++){
			for(j=0;j<9;j++){
				vertical(i,j);
				horizontal(i,j);
				square(i,j);

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

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int H = 9;
const int W = 9;

int main() {
  int T; cin >>T;
  bool ff = false;
  REP(t, T){
    if(ff) cout <<endl; ff = true;
    int v[H][W];
    REP(i, H) REP(j, W) cin >>v[i][j];
    bool f[H][W];
    memset(f, 0, sizeof(f));

    REP(i, H) REP(j, W) FOR(k, j + 1, W) if(v[i][j] == v[i][k]) f[i][j] = f[i][k] = true;
    REP(i, W) REP(j, H) FOR(k, j + 1, H) if(v[j][i] == v[k][i]) f[j][i] = f[k][i] = true;
    REP(i, 9){
      int y = (i / 3) * 3, x = (i % 3) * 3;
      REP(a, 3) REP(b, 3) REP(c, 3) REP(d, 3) if(a != c && b != d && v[a + y][b + x] == v[c + y][d + x]) f[a + y][b + x] = f[c + y][d + x] = true;
    }
    REP(i, H){
      REP(j, W) cout <<(f[i][j] ? "*" : " ") <<v[i][j];
      cout <<endl;
    }
  }
  return 0;
}