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++: /* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

int field[9][9];
const int p[] = {0, 3, 6};

char check(int y, int x)
{
  REPS(i, x, 9) if (x != i && field[y][x] == field[y][i]) return '*';
  REPS(i, y, 9) if (y != i && field[y][x] == field[i][x]) return '*';
  DEP(i, x) if (x != i && field[y][x] == field[y][i]) return '*';
  DEP(i, y) if (y != i && field[y][x] == field[i][x]) return '*';

  REPS(i, p[y / 3], p[y / 3] + 3){
    REPS(j, p[x / 3], p[x / 3] + 3){
      if (i == y && j == x) continue;
      if (field[y][x] == field[i][j]) return '*';
    }
  }

  return ' ';
}

signed main()
{
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int n;
  scanf("%d", &n);

  while (n--){
    char table[9][9];
        
    REP(i, 9) REP(j, 9) cin >> field[i][j];
    
    REP(i, 9){
      REP(j, 9){
        table[i][j] = check(i, j);
      }
    }
    REP(i, 9){
      REP(j, 9){
        printf("%c%d", table[i][j], field[i][j]);
      }
      puts("");
    }
    if (n != 0) puts("");
  }

  return (0);
}

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

int main() {
	int n;
	cin >> n;
	bool flag = false;

	for(int i = 0; i < n; i++) {
		int board[16][16];
		char mark[16][16];
		memset(mark, ' ', sizeof(mark));
		for(int j = 0; j < 9; j++)
			for(int k = 0; k < 9; k++)
				cin >> board[j][k];

		// row & comlumn
		for(int j = 0; j < 9; j++) {
			for(int k = 0; k < 9; k++) {
				for(int l = k + 1; l < 9; l++) {
					if(board[j][k] == board[j][l])
						mark[j][k] = mark[j][l] = '*';
					if(board[k][j] == board[l][j])
						mark[k][j] = mark[l][j] = '*';
				}
			}
		}

		// block
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				for(int l = 0; l < 3; l++) {
					for(int m = 0; m < 3; m++) {
						for(int n = l + (m + 1) / 3; n < 3; n++) {
							for(int o = (m + 1) % 3; o < 3; o++) {
								if(board[j * 3 + l][k * 3 + m] == board[j * 3 + n][k * 3 + o])
									mark[j * 3 + l][k * 3 + m] = mark[j * 3 + n][k * 3 + o] = '*';
							}
						}
					}
				}
			}
		}

		if(flag)
			cout << endl;

		for(int j = 0; j < 9; j++) {
			for(int k = 0; k < 9; k++) {
				cout << mark[j][k] << board[j][k];
			}
			cout << endl;
		}

		flag = true;
	}

	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int dx[9]={0,0,0,1,1,1,2,2,2},dy[9]={0,1,2,0,1,2,0,1,2};
int main(){
  int fld[9][9];
  bool num[10],fldb[9][9];
  int n;
  cin>>n;
  for(int times=0;times<n;times++){
    if(times!=0)cout<<endl;
    memset(fldb,true,sizeof(fldb));
    REP(i,9)REP(j,9)cin>>fld[j][i];
    REP(i,9)REP(j,9)REP(k,9)if(fld[i][j]==fld[i][k]&&j!=k)fldb[i][j]=false;
    REP(i,9)REP(j,9)REP(k,9)if(fld[j][i]==fld[k][i]&&j!=k)fldb[j][i]=false;
    REP(i,3)REP(j,3){
      REP(k,9)REP(l,9){
        int nx=i*3,ny=j*3;
        if(fld[nx+dx[k]][ny+dy[k]]==fld[nx+dx[l]][ny+dy[l]]&&k!=l){
          fldb[nx+dx[k]][ny+dy[k]]=false;
        }
      }
    }
    REP(i,9){
      REP(j,9){
        if(fldb[j][i])cout<<" "<<fld[j][i];
        else cout<<"*"<<fld[j][i];
      }
      cout<<endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int x[9][9], n, s[10], cnt[10], p[9][9]; bool a[9][9];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		memset(x, 0, sizeof(x));
		memset(p, 0, sizeof(p));
		memset(a, false, sizeof(a));
		memset(cnt, 0, sizeof(cnt));
		if (i) { cout << endl; }
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				cin >> x[j][k];
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[j][k]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[j][k]] >= 2) {
					a[j][k] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[k][j]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[k][j]] >= 2) {
					a[k][j] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				p[(j / 3) * 3 + (k / 3)][cnt[(j / 3) * 3 + (k / 3)]] = x[j][k];
				cnt[(j / 3) * 3 + (k / 3)]++;
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[p[j][k]]++;
			}
			for (int k = 0; k < 10; k++) {
				if (s[p[j][k]] >= 2) {
					for (int l = 0; l < 9; l++) {
						if (x[j][k] == s[p[j][k]]) {
							a[j][k] = true;
						}
					}
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				if (a[j][k] == true) {
					cout << '*';
				}
				else {
					cout << ' ';
				}
				cout << x[j][k];
			}
			cout << endl;
		}
	}
}