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>
using namespace std;
int main(){
  int n;
  int mapp[9][9];
  int koteiyoko,koteitate;
  cin>>n;
  for(int mawa=0;mawa<n;mawa++){
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	cin>>mapp[i][j];
      }
    }
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	koteiyoko=mapp[i][j];
	koteitate=mapp[j][i];
	for(int k=0;k<9;k++){
	  if(koteiyoko==mapp[i][k] && k!=j){
	    mapp[i][k]=mapp[i][k]+10;
	    mapp[i][j]=mapp[i][j]+10;
	  }
	  if(koteitate==mapp[k][i] && k!=j){
	    mapp[k][i]=mapp[k][i]+10;
	    mapp[j][i]=mapp[j][i]+10;
	  }
	}
      }
    }
    
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	if(mapp[i][j]>=10){
	  cout<<'*'<<mapp[i][j]%10;
	}else{
	  cout<<' '<<mapp[i][j];
	}
      }
      cout<<endl;
    }
  }
}

C++: /*****include*****/
#include <iostream>
#include <set>
/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
/*****変数置き場*****/
	int n;
	int field[11][11];
	bool wrong[10];
	bool fail[11][11];
	int table_x[] = {0,1,2,0,1,2,0,1,2};
	int table_y[] = {0,0,0,1,1,1,2,2,2};
	set <int>appear;
	/*****処理部*****/
	cin >> n;
	while(n>0){
		n--;
		for(int i=0;i<11;i++)
			for(int j=0;j<11;j++){
				field[i][j] = 0;
				fail[i][j] = 0;
			}
		for(int i=0;i<10;i++)
			wrong[i] = false;
		for(int i=1;i<=9;i++)
			for(int j=1;j<=9;j++)
				cin >> field[i][j];
		appear.clear();
		
		for(int i=1;i<=9;i++){
			for(int j=1;j<=9;j++){
				if(appear.find(field[i][j]) != appear.end()){
					wrong[field[i][j]] = true;
				}else
					appear.insert(field[i][j]);
			}
			appear.clear();
			for(int k=1;k<=9;k++)
				if(wrong[field[i][k]])
					fail[i][k] = true;
			for(int k=0;k<10;k++){
				wrong[k] = false;
			}
		}
		for(int j=1;j<=9;j++){
			for(int i=1;i<=9;i++){
				if(appear.find(field[i][j]) != appear.end()){
					wrong[field[i][j]] = true;
				}else
					appear.insert(field[i][j]);
			}
			appear.clear();
			for(int k=1;k<=9;k++)
				if(wrong[field[k][j]])
					fail[k][j] = true;
			for(int k=0;k<10;k++){
				wrong[k] = false;
			}
		}

		for(int i=1;i<=9;i+=3)
			for(int j=1;j<=9;j+=3){
				for(int k=0;k<9;k++)
					if(appear.find(field[i+table_y[k]][j+table_x[k]]) != appear.end())
						wrong[field[i+table_y[k]][j+table_x[k]]] = true;
					else
						appear.insert(field[i+table_y[k]][j+table_x[k]]);
				appear.clear();
				for(int k=0;k<9;k++)
					if(wrong[field[i+table_y[k]][j+table_x[k]]])
						fail[i+table_y[k]][j+table_x[k]] = true;
				for(int k=0;k<10;k++){
					wrong[k] = false;
				}
			}
		cout << endl;
		
		for(int i=1;i<=9;i++){
			for(int j=1;j<=9;j++){
				if(fail[i][j])
					cout << "*";
				else
					cout << " ";
				cout << field[i][j];
			}
			cout << endl;
		}
	}
	/*****処理終了後*****/
	return 0;
}

C++: #include <cstdio>
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
int a[9][9],b[9][9],c[10],n;
int main()
{
    scanf("%d", &n);
    while (n--) {
        rep(i, 9) rep(j, 9) b[i][j] = 0;
        rep(i, 9) rep(j, 9) scanf("%d", &a[i][j]);
        rep(i, 9) rep(j, 9) rep(k, 9) {
            if (j == k) continue;
            if (a[i][j] == a[i][k]) b[i][j] = b[i][k] = 1;
        }
        rep(i, 9) rep(j, 9) rep(k, 9) {
            if (i == k) continue;
            if (a[i][j] == a[k][j]) b[i][j] = b[k][j] = 1;
        }
        for (int i = 0; i < 9; i += 3) {
            for (int j = 0; j < 9; j += 3) {
                rep(k, 10) c[k] = 0;
                rep(k, 3) rep(l, 3) c[a[i+k][j+l]]++;
                rep(k, 3) rep(l, 3) if (c[a[i+k][j+l]] > 1) b[i+k][j+l] = 1;
            }
        }

        rep(i, 9) {
            rep(j, 9) { putchar(b[i][j] ? '*' : ' '); printf("%d", a[i][j]); }
            puts("");
        }
        if (n > 0) puts("");
    }
    return 0;
}

C++: #include<iostream>
#include<vector>

using namespace std;

int main(void){
  int n ;
  cin>>n;
  while(n--){
    vector<vector<char> > in(9,vector<char>(9));
    vector<vector<bool> > ans(9,vector<bool>(9,false));
    vector<vector<int> > usedx(9,vector<int>(9,-1));
    vector<vector<int> > usedy(9,vector<int>(9,-1));
    vector<vector<int> > usedz(9,vector<int>(9,-1));

    for(int i = 0 ; i < 9 ; i ++){
      for(int j = 0 ; j < 9 ; j ++){

	cin>>in[i][j];
	in[i][j] = in[i][j] - '1';
	
	if(usedx[i][in[i][j]] == -1){
	  usedx[i][in[i][j]] = j;
	}else{
	  ans[i][j] = true;
	  ans[i][usedx[i][in[i][j]]] = true ;
	}

	if(usedy[in[i][j]][j] == -1){
	  usedy[in[i][j]][j] = i;
	}else{
	  ans[i][j] = true;
	  ans[usedy[in[i][j]][j]][j] = true;
	}
	
	//cout<<(int)in[i][j]<<" "<<i<<" "<<j<<" "<<i/3*3+j/3<<endl;
	if(usedz[i/3*3+j/3][in[i][j]] == -1){
	  usedz[i/3*3+j/3][in[i][j]] = i*10+j;
	}else{
	  ans[i][j] = true;
	  ans[usedz[i/3*3+j/3][in[i][j]]/10][usedz[i/3*3+j/3][in[i][j]]%10] = true;
	}
      }
    }
    
    for(int i = 0 ; i < 9 ; i ++){
      for(int j = 0 ; j < 9 ; j ++){
	if(ans[i][j])cout<<"*";
	else cout<<" ";
	cout<<(int)in[i][j]+1<<" ";
      }
      cout<<endl;
    }
    if(n!=0)cout<<endl;
  }
}

C++: #include "bits/stdc++.h"

using namespace std;

#define rep(a,b) for(int (a)=0; (a)<b;(a)++)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
	int n;
	cin>>n;
	int c=0;
	rep(loop,n){
		if(c!=0)cout<<endl;
		c++;
		int data[9][9];
		bool isOK[9][9];
		rep(i,9)rep(j,9)cin>>data[i][j];

		rep(i,9)rep(j,9)isOK[i][j]=true;

		rep(i,9){
			int used[10]={};
			rep(j,9){
				used[ data[i][j] ]++;
			}
			for(int j=1;j<10;j++){
				if( used[j]>=2 ){
					rep(k,9)
						if(data[i][k]==j)
							isOK[i][k]=false;
				}
			}
		}

		rep(j,9){
			int used[10]={};
			rep(i,9){
				used[ data[i][j] ]++;
			}
			for(int i=1;i<10;i++){
				if( used[i]>=2 ){
					rep(k,9)
						if(data[k][j]==i)
							isOK[k][j]=false;
				}
			}
		}

		rep(I,3){
			rep(J,3){
				int used[10]={};
				rep(i,3){
					rep(j,3){
						used[ data[I*3+i][J*3+j] ] ++;
					}
				}
				for(int k=1;k<10;k++){
					if(used[k]>=2){
						rep(i,3){
							rep(j,3){
								isOK[I*3+i][J*3+j]=false;
							}
						}
					}
				}
			}
		}

		rep(i,9){
			rep(j,9){
				if(isOK[i][j]==true)cout<<" ";
				else cout<<"*";
				cout<<data[i][j];
			}
			cout<<endl;
		}
	}
	return 0;
}