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;
  cin >>n;
  while(n--){
    int field[9][9] = {0};
    bool flag[9][9] = {false};
    for(int i=0; i<9; i++){
      for(int j=0; j<9; j++){
	cin >>field[i][j];
      }
    }
    for(int i=0; i<9; i++){
      int log[10] = {0};
      for(int j=0; j<9; j++){
	if(log[field[i][j]] != 0){flag[i][j] = true;flag[i][log[field[i][j]]-1] = true;}
	log[field[i][j]] = j+1;
      }
    }
    for(int i=0; i<9; i++){
      int log[10] = {0};
      for(int j=0; j<9; j++){
	if(log[field[j][i]] != 0){flag[j][i] = true;flag[log[field[j][i]]-1][i] = true;}
	log[field[j][i]] = j+1;
      }
    }
    for(int i=0; i<9; i++){
      int log[10] = {0};
      for(int j=0; j<9; j++){
	if(log[field[j%3+(i%3)*3][j/3+(i/3)*3]] != 0){
	  int r = log[field[j%3+(i%3)*3][j/3+(i/3)*3]]-1;
	  flag[j%3+(i%3)*3][j/3+(i/3)*3] = true;
	  flag[r%3+(i%3)*3][r/3+(i/3)*3] = true;
	}
	log[field[j%3+(i%3)*3][j/3+(i/3)*3]] = j+1;
      }
    }
    for(int i=0; i<9; i++){
      for(int j=0; j<9; j++){
	if(flag[i][j]){cout <<"*";}
	else{cout <<" ";}
	cout <<field[i][j];
      }
      cout <<endl;
    }
    cout <<endl;
  }
  return 0;
}

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

bool isRuledCell(int x, int y, int field[9][9]) {
    for (int nx = 0; nx < 9; nx++) {
        if (x != nx && field[y][x] == field[y][nx]) {
            return false;
        }
    }
    for (int ny = 0; ny < 9; ny++) {
        if (y != ny && field[y][x] == field[ny][x]) {
            return false;
        }
    }
    for (int ny = y - (y % 3), endy = ny + 2; ny <= endy; ny++) {
        for (int nx = x - (x % 3), endx = nx + 2; nx <= endx; nx++) {
            if (y != ny && x != nx && field[y][x] == field[ny][nx]) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    bool newLineFlag = false;
    for (int i = 0; i < n; i++) {
        if (newLineFlag) {
            cout << endl;
        } else {
            newLineFlag = true;
        }
        int field[9][9];
        for (int j = 0; j < 9; j++) {
            for (int k = 0; k < 9; k++) {
                cin >> field[j][k];
            }
        }
        for (int j = 0; j < 9; j++) {
            for (int k = 0; k < 9; k++) {
                if (isRuledCell(k, j, field)) {
                    cout << " " << field[j][k];
                } else {
                    cout << "*" << field[j][k];
                }
            }
            cout << endl;
        }
    }
}

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		int field[9][9];
		rep(j, 9) rep(k, 9)
			scanf("%d", &field[j][k]);
		
		vector<vector<bool> > collect(9, vector<bool>(9, true));
		rep(j, 3){
			rep(k, 9){
				pii base;
				if(j == 0) base = pii(k, 0);
				if(j == 1) base = pii(0, k);
				if(j == 2) base = pii(k/3*3, k%3*3);
				
				int hist[9] = {0};
				rep(l, 2){
					rep(m, 9){
						pii diff;
						if(j == 0) diff = pii(0, m);
						if(j == 1) diff = pii(m, 0);
						if(j == 2) diff = pii(m/3, m%3);
						
						pii now(base.first + diff.first, base.second + diff.second);
						int a = field[now.first][now.second] - 1;
						if(!l)
							hist[a]++;
						else
							collect[now.first][now.second] = collect[now.first][now.second] & (hist[a] == 1);
					}
				}
			}
		}
		
		if(i)
			puts("");
		rep(j, 9){
			rep(k, 9)
				printf("%c%d", collect[j][k] ? ' ' : '*', field[j][k]);
			puts("");
		}
	}

	return 0;
}

C++: #include<cstdio>
using namespace std;
int main(){
  int n,m[9][9];
  char c[9][9];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    
    for(int j=0;j<9;j++){
      for(int k=0;k<9;k++){
	scanf("%d",&m[j][k]);
	c[j][k] = ' ';
      }
    }
    int dx[9] = {0,1,2,0,1,2,0,1,2};
    int dy[9] = {0,0,0,1,1,1,2,2,2};
    for(int l=0;l<9;l++){
      for(int j=0;j<8;j++){
	for(int k = j+1;k<9;k++){
	  if(m[l][j] == m[l][k]){
	    c[l][j] = '*';
	    c[l][k] = '*';
	  }
	  if(m[j][l] == m[k][l]){
	    c[j][l] = '*';
	    c[k][l] = '*';
	  }
	}
      }
    }
    
    for(int j=0;j<=6;j+=3){
      for(int k=0;k<=6;k+=3){
	for(int l=0;l<8;l++){
	  for(int o=l+1;o<9;o++){
	    if(m[j+ dy[l]][k+ dx[l]] == m[j+ dy[o]][k+ dx[o]]){
	      c[j+ dy[l]][k+ dx[l]] = '*';
	      c[j+ dy[o]][k+ dx[o]] = '*';
	    }
	  }
	}
      }
    }

    for(int j=0;j<9;j++){
      for(int k=0;k<9;k++){
	printf("%c%d",c[j][k],m[j][k]);
      }
      putchar('\n');
    }
  }
  putchar('\n');
  return (0);
}

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

void check(int g[9][9],bool f[9][9],int y,int x){
	for(int i=0; i<9; ++i){
		if(i!=y&&g[y][x]==g[i][x]){
			f[y][x]=false;
			f[i][x]=false;
			return;
		}
		if(i!=x&&g[y][x]==g[y][i]){
			f[y][x]=false;
			f[y][i]=false;
			return;
		}
	}
	int dy,dx;
	if(y<3) dy=0;
	else if(y<6) dy=3;
	else dy=6;
	if(x<3) dx=0;
	else if(x<6) dx=3;
	else dx=6;
	for(int i=0; i<3; ++i){
		for(int j=0; j<3; ++j){
			if(!(i+dy==y&&j+dx==x)&&g[y][x]==g[dy+i][dx+j]){
				f[y][x]=false;
				f[dx+i][dy+j]=false;
				return;
			}
		}
	}
}

int main(){
	int N;
	cin >> N;
	for(int i=0; i<N; ++i){
		int grids[9][9];
		bool ok[9][9];
		for(int j=0; j<9; ++j){
			for(int k=0; k<9; ++k){
				cin >> grids[j][k];
				ok[k][j]=true;
			}
		}
		for(int j=0; j<9; ++j){
			for(int k=0; k<9; ++k){
				check(grids,ok,j,k);
				if(!ok[j][k]) cout << '*';
				else cout << ' ';
				cout << grids[j][k];
				if(k==8) cout << endl;
			}
		}
	}
	return 0;
}