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 <cstring>
using namespace std;
int m[9][9][2];
int main()
{
  int n,i,j,k,l;
  bool f = false;
  cin >> n;
  while(n--){
    memset(m,0,sizeof(m));
    if(f) cout << endl;
    for(i=0;i<9;i++){
      for(j=0;j<9;j++){
	cin >> k;
	m[i][j][0] = k;
	for(k=0;k<i;k++){
	  if(m[i][j][0] == m[k][j][0]){
	    m[i][j][1] = 1;
	    m[k][j][1] = 1;
	  }
	}
	for(k=0;k<j;k++){
	  if(m[i][j][0] == m[i][k][0]){
	    m[i][j][1] = 1;
	    m[i][k][1] = 1;
	  }
	}
	for(k=(i/3)*3; k<=i; k++){
	  for(l=(j/3)*3; l<((k==i) ? j:((j/3)*3+2)); l++){
	    if(m[i][j][0] == m[k][l][0]){
	      m[i][j][1] = 1;
	      m[k][l][1] = 1;
	    }
	  }
	}
      }
    }
    for(i=0;i<9;i++){
      for(j=0;j<9;j++){
	if(m[i][j][1] == 1) cout << "*";
	else cout << " ";
	cout << m[i][j][0];
      }
      cout << endl;
    }
    f = true;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int mp[9][9],flg[9][9],visited[9][9];


void mark(int x,int y, int num){
  for(int i=y;i<y+3;i++)
    for(int j=x;j<x+3;j++)
      if(mp[i][j]==num) flg[i][j]=1;
}

void  check(int y,int x){
  int used[10]={};
  for(int i=y;i<y+3;i++)
    for(int j=x;j<x+3;j++){
      if(used[mp[i][j]]) mark(y,x,mp[i][j]);
      used[mp[i][j]]=visited[i][j]=1;
    }
}

int main(){
  int q;
  cin>>q;
  while(q--){
    for(int i=0;i<9;i++)
      for(int j=0;j<9;j++)cin>>mp[i][j];
    memset(flg,0,sizeof(flg));

    for(int i=0;i<9;i++){
      int used[10]={};
      for(int j=0;j<9;j++){
	for(int k=0;k<9&&used[mp[i][j]];k++) 
	  if(mp[i][k]==mp[i][j])flg[i][k]=1;	 
	used[mp[i][j]]=1;
      }
    }
    for(int i=0;i<9;i++){
      int used[10]={};
      for(int j=0;j<9;j++) {
	if(used[mp[j][i]])
	  for(int k=0;k<9;k++) if(mp[j][i]==mp[k][i])flg[k][i]=1;
	used[mp[j][i]]=1;
      }
    }

    memset(visited,0,sizeof(visited));
    for(int i=0;i<9;i++)
      for(int j=0;j<9;j++)
	if(visited[i][j]==0) check(i,j);

    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++)cout <<(flg[i][j]?"*":" ")<<mp[i][j];
      cout <<endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<memory.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int ii = 0; ii < n; ii++){
		int p[10][10];
		string s[10];
		int cnt[10];
		for (int i = 0; i < 9; i++){
			s[i] = "          ";
		}
		int a;
		for (int i = 0; i < 9; i++){
			for (int i2 = 0; i2 < 9; i2++){
				cin >> p[i][i2];
			}
		}
		memset(cnt, 0, sizeof(cnt));
		for (int i = 0; i < 9; i++){
			for (int i2 = 0; i2 < 9; i2++){
				cnt[p[i][i2]]++;
			}
			for (int i3 = 0; i3 < 9; i3++){
				if (cnt[i3] > 1){
					for (int i4 = 0; i4 < 9; i4++){
						if (p[i][i4] == i3){
							s[i][i4] = '*';
						}
					}
				}
			}memset(cnt, 0, sizeof(cnt));
		}

		for (int i = 0; i < 9; i++){
			for (int i2 = 0; i2 < 9; i2++){
				cnt[p[i2][i]]++;
			}
			for (int i3 = 0; i3 < 9; i3++){
				if (cnt[i3] > 1){
					for (int i4 = 0; i4 < 9; i4++){
						if (p[i4][i] == i3){
							s[i4][i] = '*';
						}
					}
				}
			}memset(cnt, 0, sizeof(cnt));
		}
		int y, x;
		y = 0; x = 0;

		for (int i = 0; i < 3; i++){
			for (int i2 = 0; i2 < 3; i2++){
				cnt[p[i2][i]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 0; i < 3; i++){
					for (int i2 = 0; i2 < 3; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 0; i < 3; i++){
			for (int i2 = 3; i2 < 6; i2++){
				cnt[p[i2][i]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 0; i < 3; i++){
					for (int i2 = 3; i2 < 6; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 0; i < 3; i++){
			for (int i2 = 6; i2 < 9; i2++){
				cnt[p[i2][i]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 0; i < 3; i++){
					for (int i2 = 6; i2 < 9; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 3; i < 6; i++){
			for (int i2 = 0; i2 < 3; i2++){
				cnt[p[i2][i]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 3; i < 6; i++){
					for (int i2 = 0; i2 < 3; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 3; i < 6; i++){
			for (int i2 = 3; i2 < 6; i2++){
				cnt[p[i2][i]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 3; i < 6; i++){
					for (int i2 = 3; i2 < 6; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 3; i < 6; i++){
			for (int i2 = 6; i2 < 9; i2++){
				cnt[p[i2][i]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 3; i < 6; i++){
					for (int i2 = 6; i2 < 9; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 6; i < 9; i++){
			for (int i2 = 0; i2 < 3; i2++){
				cnt[p[i2][i]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 6; i < 9; i++){
					for (int i2 = 0; i2 < 3; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 6; i < 9; i++){
			for (int i2 = 3; i2 < 6; i2++){
				cnt[p[i2][i]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 6; i < 9; i++){
					for (int i2 = 3; i2 < 6; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 6; i < 9; i++){
			for (int i2 = 6; i2 < 9; i2++){
				cnt[p[i2][i]]++;
			}
		}
		for (int i3 = 0; i3 < 9; i3++){
			if (cnt[i3] > 1){
				for (int i = 6; i < 9; i++){
					for (int i2 = 6; i2 < 9; i2++){
						if (p[i][i2] == i3){
							s[i][i2] = '*';
						}
					}
				}
			}
		}memset(cnt, 0, sizeof(cnt));

		for (int i = 0; i < 9; i++){
			for (int i2 = 0; i2 < 9; i2++){
				cout << s[i][i2] << p[i][i2];
			}cout << endl;
		}
	}
	
}