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 <bits/stdc++.h>
using namespace std;

int n,tb[11][11];
bool ch[11][11];

void check_ver(int x, int y){
	for(int i = 1; i <= 9; i++){
		if(i != x && tb[i][y] == tb[x][y]){
			ch[x][y] = ch[i][y] = true;
		}
	}
}
void check_hol(int x,int y){
	for(int i = 1; i <= 9; i++){
		if(i != y && tb[x][i] == tb[x][y]){
			ch[x][y] = ch[x][i] = true;
		}
	}
}
void check_blk(int x,int y){
	for(int i = ((x-1)/3)*3+1; i <= ((x-1)/3)*3+3; i++){
		for(int j = ((y-1)/3)*3+1; j <= ((y-1)/3)*3+3; j++){
			if(!(i == x && j == y) && tb[x][y] == tb[i][j]){
				ch[x][y] = ch[i][j] = true;
			}
		}
	}
}

int main(){
	scanf("%d",&n);
	for(int tm = 0; tm < n; tm++){
		for(int i = 1; i <= 9; i++){
			for(int j = 1;j <= 9; j++){
				scanf("%d",&tb[i][j]);
				ch[i][j] = false;
			}
		}
		for(int i = 1; i <= 9; i++){
			for(int j = 1;j <= 9; j++){
				check_ver(i,j);
				check_hol(i,j);
				check_blk(i,j);
			}
		}
		if(tm != 0){
			puts("");
		}
		for(int i = 1; i <= 9; i++){
			for(int j = 1;j <= 9; j++){
				printf("%c%d",ch[i][j] ? '*' : ' ',tb[i][j]);
			}
			puts("");
		}

	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int n;
int f[9][9];
int ans[9][9];
int check(int x,int y)
{
	for(int i=0;i<9;i++)
	{
		if(i==y)continue;
		if(f[x][i]==f[x][y])return 1;
	}
	for(int i=0;i<9;i++)
	{
		if(i==x)continue;
		if(f[i][y]==f[x][y])return 1;
	}
	int nx=x,ny=y;
	while(nx%3!=0)nx--;
	while(ny%3!=0)ny--;
	for(int i=nx;i<nx+3;i++)
	{
		for(int j=ny;j<ny+3;j++)
		{
			if(i==x&&j==y)continue;
			if(f[i][j]==f[x][y])return 1;
		}
	}
	return 0;
}
int main()
{
	cin >> n;
	for(int s=0;s<n;s++)
	{
		memset(ans,0,sizeof(ans));
		for(int i=0;i<9;i++)
		{
			for(int j=0;j<9;j++)
			{
				cin >> f[i][j];
			}
		}
		for(int i=0;i<9;i++)
		{
			for(int j=0;j<9;j++)
			{
				ans[i][j]=check(i,j);
			}
		}
		for(int i=0;i<9;i++)
		{
			for(int j=0;j<9;j++)
			{
				if(ans[i][j])printf("*%d",f[i][j]);
				else printf(" %d",f[i][j]);
			}
			puts("");
		}
	}
	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(x,y,mp[i][j]);
      used[mp[i][j]]=visited[i][j]=1;
    }
}

int main(){
  int q;
  cin>>q;
  int cnt=0;
  while(q--){
    if(cnt)cout <<endl;
    cnt=1;

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

int main(){
	int n;
	cin >> n;
	// input
	for( int t = 0; t < n; t++ ){
		int puzzle[9][9];
		int row[9][9] = {{0}}, col[9][9] = {{0}}, rect[9][9] = {{0}};
		for( int i = 0; i < 9; i++ ){
			for( int j = 0; j < 9; j++ ){
				cin >> puzzle[i][j];
				if( row[i][puzzle[i][j]-1] == 1 ) row[i][puzzle[i][j]-1] = -1;
				else if( row[i][puzzle[i][j]-1] == 0 ) row[i][puzzle[i][j]-1] = 1;
				if( col[j][puzzle[i][j]-1] == 1 ) col[j][puzzle[i][j]-1] = -1;
				else if( col[j][puzzle[i][j]-1] == 0 ) col[j][puzzle[i][j]-1] = 1;
				if( rect[i/3*3+j/3][puzzle[i][j]-1] == 1 ) rect[i/3*3+j/3][puzzle[i][j]-1] = -1;
				else if( rect[i/3*3+j/3][puzzle[i][j]-1] == 0 ) rect[i/3*3+j/3][puzzle[i][j]-1] = 1;
			}
		}

		// output
		if( t != 0 ) cout << endl;
		for( int i = 0; i < 9; i++ ){
			for( int j = 0; j < 9; j++ ){
				if( row[i][puzzle[i][j]-1] == -1 || col[j][puzzle[i][j]-1] == -1 || rect[i/3*3+j/3][puzzle[i][j]-1] == -1 ) cout << "*";
				else cout << " ";
				cout << puzzle[i][j];
			}
			cout << endl;
		}
	}
}