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 {
		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>
#include <string>
#include <cstring>
#include <vector>
#include <map>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	cin >> n;

	int f[9][9];
	bool flag[9][9];
	map<int,int> ma;
	
	while(n--)
	{
		memset(f,0,sizeof(f));

		rep(i,9)
		{
			rep(j,9)
			{
				flag[i][j] = false;
			}
		}

		rep(i,9)
		{
			rep(j,9)
			{
				cin >> f[i][j];
			}
		}

		/*
		rep(i,9)
		{
			rep(j,9)
			{
				cout << fixed;
				cout.width(2);
				cout<< f[i][j]-1;
			}
			cout << endl;
		}
		*/

		rep(i,9)
		{
			ma.clear();
			rep(j,9)
			{
				ma[f[i][j]-1]++;
			}

			rep(j,9)
			{
				if(ma[f[i][j]-1] > 1)
				{
					flag[i][j] = true;
				}
			}
		}
		
		
		rep(i,9)
		{
			ma.clear();
			
			rep(j,9)
			{
				ma[f[j][i]-1]++;
			}

			rep(j,9)
			{
				if(ma[f[j][i]-1] > 1)
				{
					flag[j][i] = true;
				}
			}
		}

		int count = 0;
		int x = 0,y = 0;
		while(count != 9)
		{
			ma.clear();
			REP(i,x,x+3)
			{
				REP(j,y,y+3)
				{
					ma[f[i][j]-1]++;
				}
			}

			REP(i,x,x+3)
			{
				REP(j,y,y+3)
				{
					if(ma[f[i][j]-1] > 1)
					{
						flag[i][j] = true;
					}
				}
			}

			if(x+2 == 8)
			{
				if(y+2 == 8)
				{
					break;
				}
				x = 0;
				y += 3;
			}
			else
			{
				x += 3;
			}
		}

		rep(i,9)
		{
			rep(j,9)
			{
				if(flag[i][j])
				{
					cout << "*" << f[i][j];
				}
				else
				{
					cout << " " << f[i][j];
				}
			}
			cout << endl;
		}
	}

	return 0;
}

C++: #include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
void solve() {
	int a[10][10];
	bool b[10][10];
	for0(i, 9)for0(j, 9) { cin >> a[i][j]; b[i][j] = 1; }
	int cnt[11];
	for0(i, 9) {
		for1(j, 9)cnt[j] = 0;
		for0(j, 9)cnt[a[i][j]]++;
		for0(j, 9)if (cnt[a[i][j]] > 1)b[i][j] = 0;
	}
	for0(j, 9) {
		for1(i, 9)cnt[i] = 0;
		for0(i, 9)cnt[a[i][j]]++;
		for0(i, 9)if (cnt[a[i][j]] > 1)b[i][j] = 0;
	}
	for0(x, 9) {
		for1(i, 9)cnt[i] = 0;
		for0(y, 9)cnt[a[x / 3 * 3 + y / 3][x % 3 * 3 + y % 3]]++;
		for0(y, 9)if (cnt[a[x / 3 * 3 + y / 3][x % 3 * 3 + y % 3]] > 1)b[x / 3 * 3 + y / 3][x % 3 * 3 + y % 3] = 0;
	}
	for0(i, 9) {
		for0(j, 9)cout << (b[i][j] ? ' ' : '*') << a[i][j];
		cout << endl;
	}
}
signed main() {
	int q; cin >> q; while (q--) { solve(); if (q >= 1)cout << endl; }
}

C++: #include <iostream>
using namespace std;
#define REP(i,b,c) for(int i=0;i<b;i+=c)

int main(){
	char p[9][9];
	int n;
	cin >> n;
	while(n--){
		char a[9][9];
		REP(i,9,1)REP(j,9,1)a[j][i]=' ';
		REP(i,9,1)REP(j,9,1)cin >> p[j][i];
		
		REP(j,9,3){
			REP(i,9,3){			
				int c[9]={0};
				REP(x,3,1){
					REP(y,3,1){
						c[p[i+x][j+y]-'0'-1]++;
						if(c[p[i+x][j+y]-'0'-1]>1){
							REP(t,3,1){
								REP(l,3,1){
									if(p[i+x][j+y]==p[i+t][j+l]){
										a[i+t][j+l]='*';
									}
								}
							}
						}
					}
				}	
			}
		}
		REP(i,9,1){
			int c[9]={0},c2[9]={0};
			REP(j,9,1){
				c[p[j][i]-'0'-1]++;
				if(c[p[j][i]-'0'-1]>1){
					REP(t,9,1){
						if(p[j][i]==p[t][i]){
							a[t][i]='*';
						}
					}
				}
				c2[p[i][j]-'0'-1]++;
				if(c2[p[i][j]-'0'-1]>1){
					REP(t,9,1){
						if(p[i][j]==p[i][t]){
							a[i][t]='*';
						}
					}
				}
			}
		}
		REP(i,9,1){
			REP(j,9,1)cout << a[j][i] << p[j][i];
			cout << endl;
		}
		cout << endl;
	}
}

C++: #include <iostream>

#include <cstdio>
#include <cstring>
#include <ctime>

using namespace std;

int main(){

  int n;

  cin >> n;

  int puzzle[n][9][9];
  bool cpuzzle[n][9][9];
  
  // Init flag
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 9; j++){
      for(int k = 0; k < 9; k++){
	cpuzzle[i][j][k] = false;
      }
    }
  }    

  // Loop
  for(int i = 0; i < n; i++){
    // Input
    for(int j = 0; j < 9; j++){
      for(int k = 0; k < 9; k++){
	cin >> puzzle[i][j][k];
      }
    }
    // Check
    for(int j = 0; j < 9; j++){
      for(int k = 0; k < 9; k++){
	// Check line1
	for(int l1 = 0; l1 < 9; l1++){
	  if(l1 != k){
	    if(puzzle[i][j][k] == puzzle[i][j][l1]){
	      cpuzzle[i][j][k] = true;
	    }
	  }
	}
	// Check line2
	for(int l2 = 0; l2 < 9; l2++){
	  if(l2 != j){
	    if(puzzle[i][j][k] == puzzle[i][l2][k]){
	      cpuzzle[i][j][k] = true;
	    }
	  }
	}
	// Check area
	for(int a1 = 0; a1 < 3; a1++){
	  for(int a2 = 0; a2 < 3; a2++){
	    // Area1
	    if(j >= 0 && j <= 2 && k >= 0 && k <= 2){
	      if(a1 != j && a2 != k){
		if(puzzle[i][j][k] == puzzle[i][a1][a2]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area2
	    if(j >= 3 && j <= 5 && k >= 0 && k <= 2){
	      if(a1+3 != j && a2 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+3][a2]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area3
	    if(j >= 6 && j <= 8 && k >= 0 && k <= 2){
	      if(a1+6 != j && a2 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+6][a2]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area4
	    if(j >= 0 && j <= 2 && k >= 3 && k <= 5){
	      if(a1 != j && a2+3 != k){
		if(puzzle[i][j][k] == puzzle[i][a1][a2+3]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area5
	    if(j >= 3 && j <= 5 && k >= 3 && k <= 5){
	      if(a1+3 != j && a2+3 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+3][a2+3]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area6
	    if(j >= 6 && j <= 8 && k >= 3 && k <= 5 ){
	      if(a1+6 != j && a2+3 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+6][a2+3]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area7
	    if(j >= 0 && j <= 2 && k >= 6 && k <= 8){
	      if(a1 != j && a2+6 != k){
		if(puzzle[i][j][k] == puzzle[i][a1][a2+6]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area8
	    if(j >= 3 && j <= 5 && k >= 6 && k <= 8){
	      if(a1+3 != j && a2+6 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+3][a2+6]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	    // Area9
	    if(j >= 6 && j <= 8 && k >= 6 && k <= 8){
	      if(a1+6 != j && a2+6 != k){
		if(puzzle[i][j][k] == puzzle[i][a1+6][a2+6]){
		  cpuzzle[i][j][k] = true;
		}
	      }
	    }
	  }
	}
      }
    }
    // Output
    for(int j = 0; j < 9; j++){
      for(int k = 0; k < 9; k++){
	if(cpuzzle[i][j][k]){
	  cout << "*";
	} else {
	  cout << " ";
	}
	cout << puzzle[i][j][k];
      }
      cout << endl;
    }
    if(i < n-1)cout << endl;
  }
  
  return 0;
}