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>

using namespace std;

int main() {

	int n, f[9][9], p[9][9];

	cin >> n;
	for(int c=0; c<n; c++) {
		if(c) {
			cout << endl;
		}
		for(int i=0; i<9; i++) {
			for(int j=0; j<9; j++) {
				f[i][j]=0;
				cin >> p[i][j];
			}
		}

		for(int i=0; i<9; i++) {
			for(int j=0; j<9; j++) {
				for(int k=i; k<9; k++) {
					for(int l=j; l<9; l++) {
						if(p[i][j]==p[k][l]&&(i==k||j==l)&&!(i==k&&j==l)) {
							f[i][j]=f[k][l]=1;
						}
					}
				}
			}
		}

		for(int i=0; i<9; i++) {
			for(int j=0; j<9; j++) {
				int x=(i/3)*3, y=(j/3)*3;
				for(int k=x; k<x+3; k++) {
					for(int l=y; l<y+3; l++) {
						if(p[i][j]==p[k][l]&&!(i==k&&j==l)) {
							f[i][j]=f[k][l]=1;
						}
					}
				}
			}
		}
							
		for(int i=0; i<9; i++) {
			for(int j=0; j<9; j++) {
				if(f[i][j]) {
					cout << "*" << p[i][j];
				}
				else {
					cout << " " << p[i][j];
				}
			}
			cout << endl;
		}
	}

	return 0;

}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int n;cin>>n;
    rep(hoge,n){
    vvi v(11,vi(11,0));
    rep(i,9)rep(j,9)cin>>v[i][j];
    //rep(i,9){rep(j,9)cout<<v[i][j];cout<<endl;}
    vector<vector<bool> >flag(10,vb(10,true));
    rep(j,9){
        vb used(10,false);
        rep(i,9){
            if(used[v[i][j]]==true)
            {flag[i][j]=false;
            rep(k,9)if(v[i][j]==v[k][j])flag[k][j]=false;
            }
            else used[v[i][j]]=true;
        }
    }
    rep(i,9){
        vb used(10,false);
        rep(j,9){
            if(used[v[i][j]]==true){flag[i][j]=false;
            rep(k,9)if(v[i][j]==v[k][j])flag[k][j]=false;
            else used[v[i][j]]=true;
            }
        }
    }
      for(int h=0;h<=8;h+=3){
        for(int w=0; w<=8;w+=3){
            vb used(10,false);
            for(int i=h;i<h+3;i++){
                for(int j=w; j<w+3;j++){
                    if(used[v[i][j]]){
                        flag[i][j]=false;
                        for(int l=h;l<h+3;l++)
                            for(int m=w;m<w+3;m++)
                                if(v[l][m]==v[i][j])flag[l][m]=false;
                        }
                        else if(flag[i][j]) used[v[i][j]]=true;
                    }
                }
            }
      }
    rep(i,9){
        rep(j,9){
            if(!flag[i][j])cout<<"*";
            else cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
        }
    }
}

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

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int n;
  cin >>n;
  for(int T=0; T<n; ++T){
    int i,j,k;

    int f[9][9];
    rep(i,9)rep(j,9) scanf(" %d", &f[i][j]);

    char tf[9][9];
    rep(i,9){
      rep(j,9){//f[i][j]??????????????????
        bool ok=true;

        //???
        rep(k,9){
          if(j!=k && f[i][j]==f[i][k]) ok=false;
        }

        //???
        rep(k,9){
          if(i!=k && f[i][j]==f[k][j]) ok=false;
        }

        //????????????
        int sy=3*(i/3), sx=3*(j/3);
        //printf("(%d %d) -> (%d %d)\n",i,j,sy,sx);

        for(int y=sy; y<sy+3; ++y){
          for(int x=sx ; x<sx+3; ++x){
            if(y==i&&x==j) continue;
            if(f[i][j]==f[y][x]) ok=false;
          }
        }

        if(ok) tf[i][j]=' ';
        else tf[i][j]='*';

      }
    }

    if(T) printf("\n");
    rep(i,9){
      rep(j,9){
        printf("%c%d",tf[i][j], f[i][j]);
      }
      printf("\n");
    }

  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    int field[9][9] = {0};
    bool flag[9][9] = {false};
    for(int i=0; i<9; i++){
      for(int j=0; j<9; j++){
	cin >>field[i][j];
      }
    }
    for(int i=0; i<9; i++){
      int log[10] = {0};
      for(int j=0; j<9; j++){
	if(log[field[i][j]] != 0){flag[i][j] = true;flag[i][log[field[i][j]]-1] = true;}
	log[field[i][j]] = j+1;
      }
    }
    for(int i=0; i<9; i++){
      int log[10] = {0};
      for(int j=0; j<9; j++){
	if(log[field[j][i]] != 0){flag[j][i] = true;flag[log[field[j][i]]-1][i] = true;}
	log[field[j][i]] = j+1;
      }
    }
    for(int i=0; i<9; i++){
      int log[10] = {0};
      for(int j=0; j<9; j++){
	if(log[field[j%3+(i%3)*3][j/3+(i/3)*3]] != 0){
	  int r = log[field[j%3+(i%3)*3][j/3+(i/3)*3]]-1;
	  flag[j%3+(i%3)*3][j/3+(i/3)*3] = true;
	  flag[r%3+(i%3)*3][r/3+(i/3)*3] = true;
	}
	log[field[j%3+(i%3)*3][j/3+(i/3)*3]] = j+1;
      }
    }
    for(int i=0; i<9; i++){
      for(int j=0; j<9; j++){
	if(flag[i][j]){cout <<"*";}
	else{cout <<" ";}
	cout <<field[i][j];
      }
      cout <<endl;
    }
    if(n>0){cout <<endl;}
  }
  return 0;
}

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

int main() {
	int N;
	int map[9][9];
	bool flg[9][9];
	cin >> N;
	while (N--) {
		memset(flg, 0, sizeof(flg));
		for (int i=0; i<9; i++)
		for (int j=0; j<9; j++)
			cin >> map[i][j];

		int cnt[3][9];

		for (int i=0; i<9; i++) {
		memset(cnt, 0, sizeof(cnt));
			for (int j=0; j<9; j++) {
				cnt[0][map[i][j]-1]++;
				cnt[1][map[j][i]-1]++;
				cnt[2][map[3*(i/3)+j/3][3*(i%3)+j%3]-1]++;
			}
			queue<int> q;
			for (int j=0; j<9; j++) {
				for (int k=0; k<3; k++) {
					if (cnt[k][j] > 1) q.push(k);
				}
				while (!q.empty()) {
					int p = q.front(); q.pop();
					for (int k=0; k<9; k++) {
						if (p==0&&map[i][k]==j+1) flg[i][k] = true;
						if (p==1&&map[k][i]==j+1) flg[k][i] = true;
						if (p==2&&map[3*(i/3)+k/3][3*(i%3)+j%3]==j+1) flg[3*(i/3)+k/3][3*(i%3)+k%3] = true;
					}
				}
			}
		}

		for (int i=0; i<9; i++) {
			for (int j=0; j<9; j++)
				cout << (flg[i][j] ? '*':' ') << map[i][j];
			cout << endl;
		}

		if (N) cout << endl;
	}
	return 0;
}