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 <vector>

struct Freq {
	Freq():vector(10, 0) {};
	Freq operator+(const int &i) const {
		Freq res(*this);
		++res.vector.at(i);
		return res;
	}
	Freq &operator+=(const int &i) {
		++vector.at(i);
		return (*this);
	}
	bool operator&(const int &i) const {
		return (vector.at(i) > 1);
	}
	std::vector<char> vector;
};
static const std::vector<std::pair<int, int>> square{ std::make_pair<int, int>(0, 0), std::make_pair<int, int>(1, 0), std::make_pair<int, int>(2, 0), std::make_pair<int, int>(0, 1), std::make_pair<int, int>(1, 1), std::make_pair<int, int>(2, 1), std::make_pair<int, int>(0, 2), std::make_pair<int, int>(1, 2), std::make_pair<int, int>(2, 2) };
std::vector<std::vector<char>> check(const std::vector<std::vector<int>> &map) {
	std::vector<Freq> row(9), clum(9), sq(9);
	for (auto i = 0; i < 9; ++i) {
		int sx{ (i / 3) * 3 }, sy{ (i % 3) * 3 };
		for (auto j = 0; j < 9; ++j) {
			row.at(i) += map.at(j).at(i);
			clum.at(i) += map.at(i).at(j);
			sq.at(i) += map.at(sy + square.at(j).second).at(sx + square.at(j).first);
		}
	}
	std::vector<std::vector<char>> res(9, std::vector<char>(9, ' '));
	for (auto x = 0; x < 9; ++x) {
		for (auto y = 0; y < 9; ++y) {
			if ((row.at(x) & map.at(y).at(x)) || (clum.at(y) & map.at(y).at(x)) || (sq.at((x / 3) * 3 + (y / 3)) & map.at(y).at(x))) {
				res.at(y).at(x) = '*';
			}
		}
	}
	return res;
}
int main() {
	int n;
	std::cin >> n;
	for (auto i = 0; i < n; ++i) {
		std::vector<std::vector<int>> map(9, std::vector<int>(9));
		for (auto &clum : map) {
			for (auto &cell : clum) {
				std::cin >> cell;
			}
		}
		auto res = check(map);
		for (auto y = 0; y < 9; ++y) {
			for (auto x = 0; x < 9; ++x) {
				std::cout << res.at(y).at(x) << map.at(y).at(x);
			}
			std::cout << '\n';
		}
		std::cout << std::endl;
	}
}

C++: // 2011/03/04 Tazoe

#include <iostream>
using namespace std;

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

	for(int i=0; i<n; i++){
		int puz[9][9];
		for(int j=0; j<9; j++)
			for(int k=0; k<9; k++)
				cin >> puz[j][k];

		char chk[9][9];
		for(int j=0; j<9; j++)
			for(int k=0; k<9; k++)
				chk[j][k] = ' ';

		for(int j=0; j<9; j++){
			int cnt[10] = {0};
			for(int k=0; k<9; k++)
				cnt[puz[j][k]]++;

			for(int k=0; k<9; k++)
				if(cnt[puz[j][k]]>1)
					chk[j][k] = '*';
		}

		for(int k=0; k<9; k++){
			int cnt[10] = {0};
			for(int j=0; j<9; j++)
				cnt[puz[j][k]]++;

			for(int j=0; j<9; j++)
				if(cnt[puz[j][k]]>1)
					chk[j][k] = '*';
		}

		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				int cnt[10] = {0};
				for(int j2=0; j2<3; j2++)
					for(int k2=0; k2<3; k2++)
						cnt[puz[3*j+j2][3*k+k2]]++;

				for(int j2=0; j2<3; j2++)
					for(int k2=0; k2<3; k2++)
						if(cnt[puz[3*j+j2][3*k+k2]]>1)
							chk[3*j+j2][3*k+k2] = '*';
			}
		}

		if(i!=0)
			cout << endl;

		for(int j=0; j<9; j++){
			for(int k=0; k<9; k++){
				cout << chk[j][k] << puz[j][k];
			}
			cout << endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;
 
string str;
 
int main()
{
  int n,i,j,k,l,m,a,b;
  int number[10][10];
  bool wrong[10][10];//wrong??????true*
  int check[10]={};
  
  cin>>n;
 
  rep(i,n){
    if(i)cout<<endl;
    rep(j,9)rep(k,9){
      wrong[j][k]=false;
      scanf("%d",&number[j][k]);
    }
 
    rep(j,9){//yoko check
      rep(k,10)
    check[k]=0;//0???§?????????
      rep(k,9){
    check[number[j][k]]++;
    if(check[number[j][k]]>1){//2nd
      rep(l,9)
        if(number[j][l]==number[j][k])
          wrong[j][l]=true;
         
    }
      }//repk
    }//repj
     
 
    rep(k,9){//tate check
      rep(j,10)
    check[k]=0;//?????????
      rep(j,8){
    for(l=j+1;l<9;l++)
      if(number[j][k]==number[l][k]){
        wrong[j][k]=true;
        wrong[l][k]=true;
      }
      }//repj
    }//repk
     
    rep(j,3){//block check
      rep(k,3){
    rep(l,10)
      check[l]=0;//?????????
    rep(l,3)
      rep(m,3){
      check[number[3*j+l][3*k+m]]++;
      if(check[number[3*j+l][3*k+m]]>1){//2nd
        rep(a,3)
          rep(b,3)
          if(number[3*j+a][3*k+b]==number[3*j+l][3*k+m])
        wrong[3*j+a][3*k+b]=true;
           
      }
    }
      }//repk
    }//repj
 
    rep(j,9){
      rep(k,9){
    if(wrong[j][k])
      cout<<"*";
    else
      cout<<" ";
    cout<<number[j][k];
      }
      cout<<endl;
    }
 
 
  
  }
}

C++: #include <iostream>
#include <cstring>
using namespace std;

int dataset_count;
int sudoku[9][9];
bool wrong[9][9];
int main() {
	cin >> dataset_count;
	while (dataset_count--) {
		memset(wrong, 0, sizeof(wrong));
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				cin >> sudoku[i][j];
			}
		}
		
		// 横
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				for (int k = 0; k < 9; k++) {
					if (sudoku[i][j] == sudoku[i][k] && j != k) {
						wrong[i][j] = wrong[i][k] = true;
					}
				}
			}
		}
		
		// 縦
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				for (int k = 0; k < 9; k++) {
					if (sudoku[j][i] == sudoku[k][i] && j != k) {
						wrong[j][i] = wrong[k][i] = true;
					}
				}
			}
		}

		// ブロック
		for (int i = 0; i < 9; i+=3) {
			for (int j = 0; j < 9; j+=3) {
				for (int k = i; k < i+3; k++) {
					for (int l = j; l < j+3; l++) {
						for (int m = i; m < i+3; m++) {
							for (int n = j; n < j+3; n++) {
								if (sudoku[k][l] == sudoku[m][n] && k != m && l != n) {
									wrong[k][l] = wrong[m][n] = true;
								}
							}
						}
					}
				}
			}
		}

		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				if (wrong[i][j]) cout << '*';
				else cout << ' ';
				cout << sudoku[i][j];
			}
			cout << endl;
		}
		if (dataset_count != 0) {
			cout << endl;
		}
	}

	return 0;
}