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

const int sx[] = {0, 3, 6, 0, 3, 6, 0, 3, 6};
const int sy[] = {0, 0, 0, 3, 3, 3, 6, 6, 6};

bool valid[9][9];
int puzzle[9][9];

int main()
{
  int n;
  while (~scanf("%d", &n)) {
    for (int dataset = 0; dataset < n; ++dataset) {
      if (dataset != 0)
	puts("");

      for (int i = 0; i < 9; ++i) {
	for (int j = 0; j < 9; ++j) {
	  scanf("%d", &puzzle[i][j]);
	  valid[i][j] = true;
	}
      }

      // horizonal/vertical
      for (int i = 0; i < 9; ++i) {
	vector<int> h_cnt(10, 0), v_cnt(10, 0);
	for (int j = 0; j < 9; ++j) {
	  ++h_cnt[puzzle[i][j]];
	  ++v_cnt[puzzle[j][i]];
	}
	for (int j = 0; j < 9; ++j) {
	  if (h_cnt[puzzle[i][j]] != 1)
	    valid[i][j] = false;
	  if (v_cnt[puzzle[j][i]] != 1)
	    valid[j][i] = false;
	}
      }

      // block
      for (int b = 0; b < 9; ++b) {
	vector<int> cnt(10, 0);
	for (int i = sy[b]; i < sy[b]+3; ++i) {
	  for (int j = sx[b]; j < sx[b]+3; ++j) {
	    ++cnt[puzzle[i][j]];
	  }
	}
	for (int i = sy[b]; i < sy[b]+3; ++i) {
	  for (int j = sx[b]; j < sx[b]+3; ++j) {
	    if (cnt[puzzle[i][j]] != 1)
	      valid[i][j] = false;
	  }
	}
      }

      for (int i = 0; i < 9; ++i) {
	for (int j = 0; j < 9; ++j) {
	  if (valid[i][j])
	    printf(" %d", puzzle[i][j]);
	  else
	    printf("*%d", puzzle[i][j]);
	}
	puts("");
      }
    }
  }
  return 0;
}

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+3)); 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<iostream>
#include<cstdio>
#include<string>
#include<queue>
#include<unordered_map>
#include<map>
#include<vector>
#define P pair<int,int>
using namespace std;

int main()
{
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		if (b)cout << endl;
		bool k[9][9]{};
		int c[9][9];
		for (int d = 0; d < 9; d++) {
			for (int e = 0; e < 9; e++) {
				cin >> c[d][e];
			}
		}
		for (int f = 0; f < 9; f++) {
			vector<P>h[10];
			for (int g = 0; g < 9; g++) {
				h[c[f][g]].push_back(P(f, g));
			}
			for (auto i : h) {
				if (i.size() > 1) {
					for (P j : i) {
						k[j.first][j.second] = true;
					}
				}
			}
		}
		for (int f = 0; f < 9; f++) {
			vector<P>h[10];
			for (int g = 0; g < 9; g++) {
				h[c[g][f]].push_back(P(g, f));
			}
			for (auto i : h) {
				if (i.size() > 1) {
					for (P j : i) {
						k[j.first][j.second] = true;
					}
				}
			}
		}
		for (int f = 0; f < 3; f++) {
			for (int g = 0; g < 3; g++) {
				vector<P>h[10];
				for (int k = 0; k < 3; k++) {
					for (int l = 0; l < 3; l++) {
						h[c[f * 3 + k][g * 3 + l]].push_back(P(f*3+k,g*3+l));
					}
				}
				for (auto i : h) {
					if (i.size() > 1) {
						for (P j : i) {
							k[j.first][j.second] = true;
						}
					}
				}
			}
		}
		for (int x = 0; x < 9; x++) {
			for (int y = 0; y < 9; y++) {
				if (k[x][y])cout << '*';
				else cout << ' ';
				cout << c[x][y];
			}
			cout << endl;
		}
	}
}

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[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++) {
			for (int k = 0; k < 9; k++) {
				if (a[j][k] == true) {
					cout << '*';
				}
				else {
					cout << ' ';
				}
				cout << x[j][k];
			}
			cout << endl;
		}
	}
}

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

using namespace std;

int c[9][9];
int data[9][9];


void check_1(){
  int appear[10];
  for(int i = 0; i < 9; i++){
    fill(appear,appear+10,0);
    for(int j = 0; j < 9; j++)
      appear[data[i][j]]++;
    for(int k = 0; k < 10; k++)
      if(appear[data[i][k]] > 1) c[i][k] = 1; 
  }
}

void check_2(){
  int appear[10];
  for(int i = 0; i < 9; i++){
    fill(appear,appear+10,0);
    for(int j = 0; j < 9; j++)
      appear[data[j][i]]++;
    for(int k = 0; k < 10; k++)
      if(appear[data[k][i]] > 1) c[k][i] = 1; 
  }
}

void check_3(){
  int appear[10];
  
  for(int STx = 0; STx < 9; STx+=3)
    for(int STy = 0; STy < 9; STy+=3){
      fill(appear,appear+10,0);
      for(int i = STx; i < STx+3; i++)
	for(int j = STy; j < STy+3; j++)
	  appear[data[i][j]]++;

      for(int i = STx; i < STx+3; i++)
	for(int j = STy; j < STy+3; j++)
	  if(appear[data[i][j]] > 1) c[i][j] = 1;
    }    
}

void print(){
  for(int i = 0; i < 9; i++){
    for(int j = 0; j < 9; j++){
      if(c[i][j]) cout << "*";
      else cout << " ";
      cout << data[i][j];
    }
    cout << endl;
  }
}

int main(){

  int num;
  cin >> num;
  for(int rev = 0; rev < num; rev++){
    if(rev) cout << endl;
    memset(c,0,sizeof(c));
    for(int i = 0; i < 9; i++)
      for(int j = 0; j < 9; j++)
	cin >> data[i][j];
    
    check_1();
    check_2();
    check_3();
    print();
  }
  return 0; 
}