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++: //Name: Puzzle
//Level: 2
//Category: 実装
//Note: 

/**
 * 問題文の通りに実装する。
 *
 * オーダーは O(1)。
 */
#include <iostream>
#include <vector>

using namespace std;

struct Cell {
    int val;
    bool wrong;

    Cell() : val(0), wrong(false) {}
};

void check_row(vector<vector<Cell>> &f) {
    for(int r = 0; r < 9; ++r) {
        int cnt[10] = {0};
        for(int c = 0; c < 9; ++c) {
            cnt[f[r][c].val]++;
        }
        for(int c = 0; c < 9; ++c) {
            if(cnt[f[r][c].val] > 1) f[r][c].wrong = true;
        }
    }
}

void check_col(vector<vector<Cell>> &f) {
    for(int c = 0; c < 9; ++c) {
        int cnt[10] = {0};
        for(int r = 0; r < 9; ++r) {
            cnt[f[r][c].val]++;
        }
        for(int r = 0; r < 9; ++r) {
            if(cnt[f[r][c].val] > 1) f[r][c].wrong = true;
        }
    }
}

void check_sq(vector<vector<Cell>> &f) {
    for(int r = 0; r < 9; r += 3) {
        for(int c = 0; c < 9; c += 3) {
            int cnt[10] = {0};
            for(int dr = 0; dr < 3; ++dr) {
                for(int dc = 0; dc < 3; ++dc) {
                    cnt[f[r+dr][c+dc].val]++;
                }
            }
            for(int dr = 0; dr < 3; ++dr) {
                for(int dc = 0; dc < 3; ++dc) {
                    if(cnt[f[r+dr][c+dc].val] > 1) f[r+dr][c+dc].wrong = true;
                }
            }
        }
    }
}

bool solve(bool first) {
    vector<vector<Cell>> f(9, vector<Cell>(9));
    for(int r = 0; r < 9; ++r) {
        for(int c = 0; c < 9; ++c) {
            cin >> f[r][c].val;
        }
    }
    if(!first) cout << endl;

    check_row(f);
    check_col(f);
    check_sq(f);
    for(int r = 0; r < 9; ++r) {
        for(int c = 0; c < 9; ++c) {
            cout << (f[r][c].wrong ? '*' : ' ') << f[r][c].val;
        }
        cout << endl;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    bool first = true;
    int N;
    cin >> N;
    while(N--) {
        solve(first);
        first = false;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int a[9][9];
bool f[9][9];
int main(){
  int n;
  cin>>n;
  while(n--){
    r(i,9)r(j,9){cin>>a[i][j];f[i][j]=false;}
    int c[10];
    r(i,9){memset(c,0,sizeof(c));r(j,9)c[a[i][j]]++;
      r(j,9)if(1<c[a[i][j]])f[i][j]=true;
    }
    r(j,9){memset(c,0,sizeof(c));r(i,9)c[a[i][j]]++;
      r(i,9)if(1<c[a[i][j]])f[i][j]=true;
    }
    for(int y=0;y<9;y+=3)for(int x=0;x<9;x+=3){
      memset(c,0,sizeof(c));
      r(i,3)r(j,3)c[a[y+i][x+j]]++;
      r(i,3)r(j,3)if(1<c[a[y+i][x+j]])f[y+i][x+j]=true;
    }
    r(i,9){r(j,9){
      if(f[i][j])cout<<'*';
      else cout<<' ';
      cout<<a[i][j];
    }
    cout<<endl;
  }
  if(n)cout<<endl;
}
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  rep(i,n){
    vector<vector<int>> v(9,vector<int>(9,0));
    vector<vector<char>> v2(9,vector<char>(9,' '));
    if( i != 0) cout << endl;
    rep(i,9){
      rep(j,9){
        cin>>v[j][i];
      }
    }
    rep(i,9){
      int num[10] = {};
      rep(j,9){
        num[v[j][i]]++;
      }
      rep(j,9){
        if(num[v[j][i]] > 1){
          v2[j][i] = '*';
        }
      }
    }
    rep(j,9){
      int num[10] = {};
      rep(i,9){
        num[v[j][i]]++;
      }
      rep(i,9){
        if(num[v[j][i]] > 1){
          v2[j][i] = '*';
        }
      }
    }
    for(int i = 0; i < 9 ; i+= 3){
      for(int j = 0; j < 9; j += 3){
        int num[10]={};
        rep(k,3){
          rep(l,3){
            num[v[j+l][i+k]]++;
          }
        }
        rep(k,3){
          rep(l,3){
            if(num[v[j+l][i+k]] > 1){
              v2[j+l][i+k] = '*';
            }
          }
        }
      }
    }
    rep(i,9){
      rep(j,9){
        cout << v2[j][i]<<v[j][i];
      }
      cout << endl;
    }
  }
  return 0;
}