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 <cstdio>
using namespace std;

int main(){
    int N;
    for(scanf("%d", &N); N--;){
        char pz[9][12] = {};
        char res[9][12] = {};
        for(int i = 0; i < 9; i++){
            for(int j = 0; j < 9; j++){
                scanf(" %c", &pz[i][j]);
            }
        }
        for(int i = 0; i < 9; i++){
            for(int j = 0; j < 9; j++){
                bool flg = true;
                for(int k = 0; k < 9; k++){
                    if(i == k) continue;
                    if(pz[i][j] == pz[k][j]) flg = 0;
                }
                for(int k = 0; k < 9; k++){
                    if(j == k) continue;
                    if(pz[i][j] == pz[i][k]) flg = 0;
                }
                if(flg){
                    res[i][j] = ' ';
                }else{
                    res[i][j] = '*';
                }
            }
        }
        for(int i = 0; i < 9; i++){
            for(int j = 0; j < 9; j++){
                printf("%c", res[i][j]);
                printf("%c", pz[i][j]);
            }
            puts("");
        }
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>

using namespace std;

int main(){

	int n;
	cin>>n;

	//set<pair<int,int> > wrong;

	for(int i = 0; i < n; i++){
		bool wrong[10][10];
		memset(wrong,0,sizeof(wrong));
		int field[10][10];
		for(int j = 0; j < 9; j++){
			for(int k = 0; k < 9; k++){
				cin>>field[j][k];
			}
		}
		// row
		for(int j = 0; j < 9; j++){
			vector<pair<int,int> > p[10];
			for(int k = 0; k < 9; k++){
				p[field[k][j]].push_back(make_pair(k,j));
			}
			// 2ツ禿アツ度ツ暗按湘」ツ出ツ個サツつオツづつ「ツつスツづァツ、wrongツづ永nsert
			for(int k = 1; k < 10; k++){
				if(p[k].size()>=2){
					for(int l = 0; l < p[k].size(); l++){
						//wrong.insert(p[k][l]);
						wrong[p[k][l].first][p[k][l].second]=true;
					}
				}
			}
		}
		// cow
		for(int j = 0; j < 9; j++){
			vector<pair<int,int> > p[10];
			for(int k = 0; k < 9; k++){
				p[field[j][k]].push_back(make_pair(j,k));
			}
			// 2ツ禿アツ度ツ暗按湘」ツ出ツ個サツつオツづつ「ツつスツづァツ、wrongツづ永nsert
			for(int k = 1; k < 10; k++){
				if(p[k].size()>=2){
					for(int l = 0; l < p[k].size(); l++){
						wrong[p[k][l].first][p[k][l].second]=true;
					}
				}
			}
		}
		// mergin
		for(int j = 0; j < 7; j+=3){
			for(int k = 0; k < 7; k+=3){
				if(j==9&&k==0){
					cout<<endl;
				}
				// (k,j)ツづ個地ツ点ツつゥツづァツ探ツ催オツつキツづゥ
				vector<pair<int,int> > p[10];
				for(int l = 0; l < 3; l++){
					for(int m = 0; m < 3; m++){
						p[field[j+l][k+m]].push_back(make_pair(j+l,k+m));
					}
				}
				// 2ツ禿アツ度ツ暗按湘」ツ出ツ個サツつオツづつ「ツつスツづァツ、wrongツづ永nsert
				for(int l = 1; l < 10; l++){
					if(p[l].size()>=2){
						for(int m = 0; m < p[l].size(); m++){
							wrong[p[l][m].first][p[l][m].second]=true;
						}
					}
				}
			}
		}

		for(int j = 0; j < 9; j++){
			for(int k = 0; k < 9; k++){
				if(wrong[j][k]){
					cout<<'*';
				}
				else
					cout<<' ';
				cout<<field[j][k];
			}
			cout<<endl;
		}
		if(i!=n-1)
			cout<<endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
int p[10][10];
bool f[10][10];
using namespace std;

void ck(int x, int y){
  rep(i, 9){
    if(i != x && p[i][y] == p[x][y]) f[i][y] = f[x][y] = 1;
    if(i != y && p[x][i] == p[x][y]) f[x][i] = f[x][y] = 1;
  }
  FOR(i, 3 * (x / 3), 3 * ((x / 3) + 1)) FOR(j, 3 * (y / 3), 3 * ((y / 3)+1)){
    if(i == x && j == y) continue;
    if(p[i][j] == p[x][y])
      f[i][j] = f[x][y] = 1;
  }
} 
				       
int main(){
  int n;
  scanf("%d", &n);
  rep(i, n){
    if(i != 0) puts("");
    rep(i, 9) rep(j, 9) f[j][i] = 0;
    rep(i, 9) rep(j, 9)
      scanf("%d", &p[i][j]);

    rep(i, 9){
      rep(j, 9){
	ck(i, j);
	printf(f[i][j] ? "*":" ");
	printf("%d", p[i][j]);
      }
      puts("");
    }
  }
  return 0;
}