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<set>
#include<utility>
#include<cstring>

typedef std::pair<int, int> P;

bool ver[9][9], hor[9][9], sq[9][9];
int n;
char puzzle[9][9];
std::set<int> s[3][9];

// k: 0 -> ver, 1 -> hor, 2 -> sq
int f( int k, int i, int j )
{
	switch( k )
	{
		case 0:
			return j;
		case 1:
			return i;
		case 2:
			return i / 3 * 3 + j / 3;
	}
}

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

	bool fst = true;
	while( n-- )
	{
		memset( ver, false, sizeof( ver ) );
		memset( hor, false, sizeof( hor ) );
		memset( sq, false, sizeof( sq ) );
		for( int i = 0; i != 3; ++i )
			for( int j = 0; j != 9; ++j )
				s[i][j].clear();

		for( int i = 0; i != 9; ++i )
		{
			for( int j = 0; j != 9; ++j )
			{
				std::cin >> puzzle[i][j];
	
				int t = puzzle[i][j] - '1';
				int fl = ver[f(0, i, j)][t] | ( hor[f(1, i, j)][t] << 1 ) | ( sq[f(2, i, j)][t] << 2 );

				if( !fl ) 
					ver[f(0, i, j)][t] = hor[f(1, i, j)][t] = sq[f(2, i, j)][t] = true;
				else
				{
					for( int k = 0; k != 3; ++k )
						if( fl >> k & 1 )
							s[k][f(k, i, j)].insert( t );
				}
			}
		}

		if( !fst )
			std::cout << std::endl;

		for( int i = 0; i != 9; ++i )
		{
			for( int j = 0; j != 9; ++j )
			{
				bool fl = false;
				for( int k = 0; k != 3; ++k )
					fl |= s[k][f(k, i, j)].count( puzzle[i][j] - '1' );

				std::cout << ( fl ? '*' : ' ' ) << puzzle[i][j]; 
			}
			
			std::cout << std::endl;
		}

		fst = false;
	}

	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
int p[10][10];
bool f[10][10];
using namespace std;
 
void ck(int x, int y){
  rep(i, 9){
    if(i != x && p[i][y] == p[x][y]) f[i][y] = f[x][y] = 1;
    if(i != y && p[x][i] == p[x][y]) f[x][i] = f[x][y] = 1;
  }
  FOR(i, 3 * (x / 3), 3 * ((x / 3) + 1)) FOR(j, 3 * (y / 3), 3 * ((y / 3)+1)){
    if(i == x && j == y) continue;
    if(p[i][j] == p[x][y])
      f[i][j] = f[x][y] = 1;
  }
} 
                        
int main(){
  int n;
  scanf("%d", &n);
  rep(i, n){
    if(i != 0) puts("");
    rep(i, 9) rep(j, 9) f[j][i] = 0;
    rep(i, 9) rep(j, 9)
      scanf("%d", &p[i][j]);
 
    rep(i, 9){
      rep(j, 9){
    ck(i, j);
    printf(f[i][j] ? "*":" ");
    printf("%d", p[i][j]);
      }
      puts("");
    }
  }
  return 0;
}

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[p[j][k]]++;
			}
			for (int k = 0; k < 10; k++) {
				if (s[p[j][k]] >= 2) {
					for (int l = 0; l < 9; l++) {
						if (x[j][l] == k) {
							a[j][l] = 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 <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(){
  bool error[10][10];
  int puzzle[10][10];
  
  int T;
  cin >> T;
  while(T--){
    for(int i = 0 ; i < 9 ; i++){
      for(int j = 0 ; j < 9 ; j++){
	cin >> puzzle[i][j];
      }
    }
    
    memset(error, 0, sizeof(error));
    int check1[10];
    int check2[10];
    
    for(int i = 0 ; i < 9 ; i++){
      memset(check1, 0, sizeof(check1));
      memset(check2, 0, sizeof(check2));
      for(int j = 0 ; j < 9 ; j++){
	check1[puzzle[i][j]]++;
	check2[puzzle[j][i]]++;
	
	if(check1[puzzle[i][j]] >= 2){
	  for(int k = 0 ; k < 9 ; k++){
	    if(puzzle[i][k] == puzzle[i][j]) error[i][k] = true;
	  }
	}
	
	if(check2[puzzle[j][i]] >= 2){
	  for(int k = 0 ; k < 9 ; k++){
	    if(puzzle[k][i] == puzzle[j][i]) error[k][i] = true;
	  }
	}
	
      }
    }

    for(int k = 0 ; k < 9 ; k+=3){
      memset(check1, 0, sizeof(check1));
      memset(check2, 0, sizeof(check2));
      for(int i = k ; i < k+3 ; i++){
	for(int j = 0 ; j < 3 ; j++){
	  check1[puzzle[i][j]]++;
	  if(check1[puzzle[i][j]] >= 2){
	    for(int _i = k ; _i < k+3 ; _i++){
	      for(int _j = 0 ; _j < 3 ; _j++){
		if(puzzle[i][j] == puzzle[_i][_j]) error[_i][_j] = true;
	      }
	    }
	  }
	}
      }
    }

    for(int k = 0 ; k < 9 ; k+=3){
      memset(check1, 0, sizeof(check1));
      memset(check2, 0, sizeof(check2));
      for(int i = k ; i < k+3 ; i++){
	for(int j = 3 ; j < 6 ; j++){
	  check1[puzzle[i][j]]++;
	  if(check1[puzzle[i][j]] >= 2){
	    for(int _i = k ; _i < k+3 ; _i++){
	      for(int _j = 3 ; _j < 6 ; _j++){
		if(puzzle[i][j] == puzzle[_i][_j]) error[_i][_j] = true;
	      }
	    }
	  }
	}
      }
    }

    for(int k = 0 ; k < 9 ; k+=3){
      memset(check1, 0, sizeof(check1));
      memset(check2, 0, sizeof(check2));
      for(int i = k ; i < k+3 ; i++){
	for(int j = 6 ; j < 9 ; j++){
	  check1[puzzle[i][j]]++;
	  if(check1[puzzle[i][j]] >= 2){
	    for(int _i = k ; _i < k+3 ; _i++){
	      for(int _j = 6 ; _j < 9 ; _j++){
		if(puzzle[i][j] == puzzle[_i][_j]) error[_i][_j] = true;
	      }
	    }
	  }
	}
      }
    }
	
    
    for(int i = 0 ; i < 9 ; i++){
      for(int j = 0 ; j < 9 ; j++){
	cout << ((error[i][j]) ? '*' : ' ') << puzzle[i][j];
      }
      cout << endl;
    }
    if(T)cout << endl;
  }
  return 0;
}