Go: package main

import (
	"bufio"
		"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)
	for 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<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int board[10][10];
int main(){
	cin>>n;
	for(int k = 0;k< n;k++){
		bool flag[10][10];
		rep(i,10){
			rep(j,10){
				flag[i][j] = true;
			}
		}
		for(int y = 1;y <=9;y++){
			for(int x = 1;x <=9;x++){
				cin>>board[y][x];
			}
		}
		for(int y = 1; y<=9;y+=3){//3×3ブロックごとの判定
			for(int x = 1;x <=9;x+=3){
				int cnt[10]={0};
				rep(i,3){
					rep(j,3){
						cnt[board[y+i][x+j]]+=1;
					}
				}
				rep(i,3){
					rep(j,3){
						if(cnt[board[y+i][x+j]]!=1){
							flag[y+i][x+j] =false;
						}
					}
				}
			}
		}
		for(int y = 1;y <=9;y++){//横の判定
			int cnt[10]={0};
			for(int x = 1;x <=9;x++){
				cnt[board[y][x]]+=1;
			}
			for(int x = 1; x<=9;x++){
				if(cnt[board[y][x]]!=1){
					flag[y][x] =false;
				}
			}
		}
		for(int x = 1;x <=9;x++){
			int cnt[10]={0};
			for(int y =1;y <=9;y++){
				cnt[board[y][x]]++;
			}
			for(int y = 1;y <=9;y++){
				if(cnt[board[y][x]]!=1){
					flag[y][x] = false;
				}
			}
		}
		for(int i = 1;i <=9;i++){
			for(int j = 1;j <=9;j++){
				printf("%c%d",(flag[i][j]?' ':'*'),board[i][j]);
			}
			cout <<endl;
		}
	}
	return 0;
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N;
	cin >> N;
	while (N--) {
		int field[9][9];
		for (int i = 0; i < 9; ++i) {
			for (int j = 0; j < 9; ++j) {
				cin >> field[i][j];
			}
		}
		vector<vector<int>>oks(9, vector<int>(9,true));
		for (int i = 0; i < 9; ++i) {
			for (int j = 0; j < 9; ++j) {
				for (int k = 0; k < 9; ++k) {
					if (j == k)continue;
					if (field[i][j] == field[i][k])oks[i][j] = false;
				}
				for (int k = 0; k < 9; ++k) {
					if (i == k)continue;
					if (field[i][j] == field[k][j])oks[i][j] = false;
				}
				int ax = j / 3;
				int ay = i / 3;
				for (int k = ax * 3; k < ax * 3 + 3; ++k) {
					for (int l = ay * 3; l < ay * 3 + 3; ++l) {
						if (k == j&&l == i)continue;
						if (field[i][j] == field[l][k])oks[i][j] = false;
					}
				}
			}
		}
		for (int i = 0; i < 9; ++i) {
			for (int j = 0; j < 9; ++j) {
				if (oks[i][j])cout << " ";
				else cout << "*";
				cout << field[i][j];
			}
			cout << endl;
		}
		if(N!=1)cout << endl;
		
	}
	return 0;
}

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){
	  error[i][j] = 1;
	  for(int k = 0 ; k < 9 ; k++){
	    if(puzzle[i][k] == puzzle[i][j]) error[i][k] = 1;
	  }
	}
	  
	if(check2[puzzle[j][i]] >= 2){
	  error[j][i] = 1;
	  for(int k = 0 ; k < 9 ; k++){
	    if(puzzle[k][i] == puzzle[j][i]) error[k][i] = 1;
	  }
	}
	
      }
    }
    
    for(int i = 0 ; i < 9 ; i++){
      for(int j = 0 ; j < 9 ; j++){
	cout << ((error[i][j]) ? '*' : ' ') << puzzle[i][j];
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<set>
#include<utility>
#include<cstring>

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

bool used[3][9][9];
int n;
char puzzle[9][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( used, false, sizeof( used ) );
		
		std::set<int> s[3][9];
		
		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 = 0;
				for( int k = 0; k != 3; ++k )
					fl |= (used[k][f(k,i,j)][t] << k);

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

		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;
}