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 <iostream>
#include <cstring>

using namespace std;

int dx[3]={0,3,6};
int dy[3]={0,3,6};

int main(void){
	int n;
	bool first = true;;
	cin >> n;
	
	for(int i=0;i<n;i++){
		int mat[9][9];
		bool ast[9][9];
		int worksp[10];
		
		
		if(!first) cout << endl;
		memset(ast, false, sizeof(ast));
		for(int j=0;j<9;j++){
			for(int k=0;k<9;k++){
				cin >> mat[j][k];
			}
		}
		
		//check every rows
		for(int j=0;j<9;j++){
			memset(worksp, -1, sizeof(worksp));
			
			for(int k=0;k<9;k++){
				if(worksp[mat[j][k]] == -1){ //unexist yet
					worksp[mat[j][k]] = k;
				}else{
					ast[j][k] = true;
					ast[j][worksp[mat[j][k]]] = true;
					//cout << "line " << mat[j][k] << endl;
				}
			}
		}
		//check every cols
		for(int j=0;j<9;j++){
			memset(worksp, -1, sizeof(worksp));
			
			for(int k=0;k<9;k++){
				if(worksp[mat[k][j]] == -1){ //unexist yet
					worksp[mat[k][j]] = k;
				}else{
					ast[k][j] = true;
					ast[worksp[mat[k][j]]][j] = true;
					//cout << "cols " << mat[k][j] << endl;
				}
			}
		}
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				memset(worksp, -1, sizeof(worksp));
				
				for(int p=0;p<3;p++){
					for(int q=0;q<3;q++){
						if(worksp[mat[dx[j]+p][dy[k]+q]] == -1){
							worksp[mat[dx[j]+p][dy[k]+q]] = p*10+q;
						}else{
							ast[dx[j]+p][dy[k]+q] = true;
							ast[dx[j] + worksp[mat[dx[j]+p][dy[k]+q]] / 10][dy[k] + worksp[mat[dx[j]+p][dy[k]+q]] % 10] = true;
						}
					}
				}
			}
		}
		//check every square
		
		for(int j=0;j<9;j++){
			for(int k=0;k<9;k++){
				if(ast[j][k]){
					cout << "*" << mat[j][k];
				}else{
					cout << " " << mat[j][k];
				}
			}
			cout << endl;
		}
		first = false;
	}
}

C++: #include<stdio.h>
int table[9][9];
bool NG[9][9];
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
				scanf("%d",&table[i][j]);
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
				NG[i][j]=false;
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				bool ok=true;
				for(int k=0;k<9;k++){
					if(table[i][j]==table[i][k]&&j!=k)ok=false;
				}
				for(int k=0;k<9;k++){
					if(table[i][j]==table[k][j]&&i!=k)ok=false;
				}
				int seci=i/3;
				int secj=j/3;
				for(int k=0;k<3;k++){
					for(int 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)NG[i][j]=true;
			}
		}
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				printf(NG[i][j]?"*":" ");
				printf("%d",table[i][j]);
			}
			printf("\n");
		}
		printf("\n");
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second


main(){
  int n;
  cin>>n;
  while(n--){
    map<int,int> masu[9],tate[9],yoko[9];
    int puz[9][9];
    rep(i,9)rep(j,9){
      cin>>puz[i][j];
      masu[i/3*3+j/3][puz[i][j]]++;
      tate[i][puz[i][j]]++;
      yoko[j][puz[i][j]]++;
    }

    rep(i,9){
      rep(j,9){
        if(masu[i/3*3+j/3][puz[i][j]]>1 || tate[i][puz[i][j]]>1 || yoko[j][puz[i][j]]>1)cout<<"*";
        else cout<<" ";
        cout<<puz[i][j];
      }
      cout<<endl;
    }
    if(n)cout<<endl;
  }
}

C++: #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
#define INF 1e+8
#define EPS 1e-8
#define PB push_back
#define fi first
#define se second
#define reps(i,j,k) for(int i = j; i < k; i++)
#define rep(i,j) reps(i,0,j)
using namespace std;
const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
typedef long long ll;
typedef pair<int,int> Pii;

int main(){
	int N;
	scanf("%d",&N);
	const int hoge = N;
	rep(n,hoge){
		int field[10][10];
		bool fail[10][10]={{0}};
		rep(i,9){
			rep(j,9){
				scanf("%d",&field[i][j]);
			}
		}
		//よこ
		rep(i,9){
			int cnt[10]={0};
			rep(j,9){
				cnt[field[i][j]]++;
			}
			rep(j,10){
				if(cnt[j]>1){
					rep(k,9){
						if(field[i][k]==j)fail[i][k]=1;
					}
				}
			}
		}
		//たて
		rep(i,9){
			int cnt[10]={0};
			rep(j,9){
				cnt[field[j][i]]++;
			}
			rep(j,10){
				if(cnt[j]>1){
					rep(k,9){
						if(field[k][i]==j)fail[k][i]=1;
					}
				}
			}
		}
		//わく
		for(int i = 0; i < 9;i+=3){
			for(int j = 0; j < 9; j+=3){
				int cnt[10]={0};
				reps(k,i,i+3){
					reps(l,j,j+3){
						cnt[field[k][l]]++;
					}
				}
				rep(m,10){
					if(cnt[m]>1){
						reps(k,i,i+3){
							reps(l,j,j+3){
								if(field[k][l] == m)fail[k][l]=1;
							}
						}
					}
				}
			}
		}
		rep(i,9){
			rep(j,9){
				printf("%c%d",fail[i][j]==1?'*':' ',field[i][j]);
			}
			puts("");
		}
		n == hoge-1?printf(""):puts("");
	}
	return 0;
}