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 <stdlib.h>

using namespace std;

int dir[9][2] = {
	{-1, -1},
	{0, -1},
	{1, -1},
	{-1, 0},
	{0, 0},
	{1, 0},
	{-1, 1},
	{0, 1},
	{1, 1}
};

int main(int argc, char **argv)
{
	int **array, **array2, *array3, n;
	
	cin >> n;
	for(int t = 0; t < n; t++){
		array = (int **)calloc(9, sizeof(int));
		array2 = (int **)calloc(9, sizeof(int));
		for(int i = 0; i < 9; i++){
			array[i] = (int *)calloc(9, sizeof(int));
			array2[i] = (int *)calloc(9, sizeof(int));
		}
		
		for(int i = 0; i < 9; i++){
			array3 = (int *)calloc(10, sizeof(int));
			for(int j = 0; j < 9; j++){
				cin >> array[i][j];
				array3[array[i][j]]++;
			}
			
			for(int k = 1; k <= 9; k++){
				if(array3[k] > 1){
					for(int j = 0; j < 9; j++){
						if(k == array[i][j]){
							array2[i][j] = 1;
						}
					}
				}
			}
			
			free(array3);
		}
		
		for(int i = 0; i < 9; i++){
			array3 = (int *)calloc(10, sizeof(int));
			for(int j = 0; j < 9; j++){
				array3[array[j][i]]++;
			}
			
			for(int k = 1; k <= 9; k++){
				if(array3[k] > 1){
					for(int j = 0; j < 9; j++){
						if(k == array[j][i]){
							array2[j][i] = 1;
						}
					}
				}
			}
			free(array3);
		}
		
		for(int i = 1; i < 9; i+=3){
			for(int j = 1; j < 9; j+=3){
				array3 = (int *)calloc(10, sizeof(int));
				for(int k = 0; k < 9; k++){
					array3[array[i+dir[k][0]][j+dir[k][1]]]++;
				}
				
				for(int k = 1; k <= 9; k++){
					if(array3[k] > 1){
						for(int l = 0; l < 9; l++){
							if(k == array[i+dir[l][0]][j+dir[l][1]]){
								array2[i+dir[l][0]][j+dir[l][1]] = 1;
							}
						}
					}
				}
				
				free(array3);
			}
		}
		
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				if(array2[i][j] == 0){
					cout << " " << array[i][j];
				} else {
					cout << "*" << array[i][j];
				}
			}
			cout << endl;
		}
		
		for(int i = 0; i < 9; i++){
			free(array[i]);
			free(array2[i]);
		}
		free(array);
		free(array2);
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int suudoku[n][9][9];
  int Map[n][9][9];
  for(int k=0;k<n;k++)
    for(int i=0;i<9;i++)
      for(int j=0;j<9;j++)
	Map[k][i][j]=0;
  for(int aa=0;aa<n;aa++){
    for(int i=0;i<9;i++)
      for(int j=0;j<9;j++)
	cin>>suudoku[aa][i][j];
    for(int i=0;i<9;i++){
      int suuretu[10]={};
      for(int j=0;j<10;j++)
	suuretu[j]=-1;
      for(int j=0;j<9;j++){
	if(suuretu[suudoku[aa][j][i]]!=-1){
	  Map[aa][j][i]=1;
	  Map[aa][suuretu[suudoku[aa][j][i]]][i]=1;
	}else{
	  suuretu[suudoku[aa][j][i]]=j;
	}
      }
    }
    for(int i=0;i<9;i++){
      int suuretu[10]={};
      for(int j=0;j<10;j++)
	suuretu[j]=-1;
      for(int j=0;j<9;j++){
	if(suuretu[suudoku[aa][i][j]]!=-1){
	  Map[aa][i][j]=1;
	  Map[aa][suuretu[suudoku[aa][i][j]]][j]=1;
	}else{
	  suuretu[suudoku[aa][i][j]]=i;
	}
      }
    }
    for(int i=0;i<9;i+=3){
      int suuretu[10]={};
      for(int j=0;j<10;j++)
	suuretu[j]=-1;
      for(int l=0;l<9;l+=3){
	for(int j=i;j<i+3;j++){
	  for(int k=l;k<l+3;k++){
	    //cout<<suudoku[aa][j][k]<<" ";
	    if(suuretu[suudoku[aa][j][k]]!=-1){
	      Map[aa][j][k]=1;
	      Map[aa][suuretu[suudoku[aa][j][k]]][k]=1;
	    }else{
	      suuretu[suudoku[aa][j][k]]=k;
	    }
	  }
	  //cout<<endl;
	}
      }
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<9;j++){
      for(int k=0;k<9;k++){
	if(Map[i][j][k]==1){
	  cout<<"*";
	}else{
	  cout<<" ";
	}
	cout<<suudoku[i][j][k];
      }
      if(i!=n-1||j!=8)
      cout<<endl;
    }
    if(i!=n-1)
      cout<<endl;
  }
  return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto& e:c)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); ++it)

ll const inf = 1<<28;
double const pi = acos(-1);

int g[9][9];
bool ok[9][9];

void solve(){
    rep(y,9)rep(x,9){
        if(!ok[y][x]) continue;
        loop(i,y+1,9){
            if(g[y][x]==g[i][x]){
                ok[i][x]=false;
                ok[y][x]=false;
            }
        }

        loop(j,x+1,9){
            if(g[y][x]==g[y][j]){
                ok[y][j]=false;
                ok[y][x]=false;
            }
        }
    }

    rep(i,3)rep(j,3){
        rep(a,9){
            int x=a%3+i*3;
            int y=a/3+j*3;
            loop(b,a+1,9){
                int xx=b%3+i*3;
                int yy=b/3+j*3;
                if(g[y][x]==g[yy][xx]){
                    ok[yy][xx]=false;
                    ok[y][x]=false;
                }
            }
        }
    }
}

int main(){
    int n;
    cin>>n;
    rep(i,n){
        rep(y,9)rep(x,9){
            ok[y][x]=true;
        }
        rep(y,9)rep(x,9)cin>>g[y][x];
        solve();
        rep(y,9)rep(x,9){
            printf("%c%d",ok[y][x]?' ':'*',g[y][x]);
            if(x+1==9)puts("");
        }
        if(i+1!=n)puts("");
    }
}