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 <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int dy[] = {0, 0, 0, 1, 1, 1, 2, 2, 2};
int dx[] = {0, 1, 2, 0, 1, 2, 0, 1, 2};

void solve() {
  int a[9][9], wa[9][9] = {};
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cin >> a[i][j];
    }
  }
  for (int d = 1; d < 10; d++) {
    for (int i = 0; i < 9; i++) {
      int cnt = 0;
      for (int j = 0; j < 9; j++) {
        cnt += a[i][j] == d;
      }
      if (cnt == 1) continue;
      for (int j = 0; j < 9; j++) {
        if (a[i][j] == d) wa[i][j] = 1;
      }
    }
    for (int j = 0; j < 9; j++) {
      int cnt = 0;
      for (int i = 0; i < 9; i++) {
        cnt += a[i][j] == d;
      }
      if (cnt == 1) continue;
      for (int i = 0; i < 9; i++) {
        if (a[i][j] == d) wa[i][j] = 1;
      }
    }
    for (int i = 0; i < 9; i += 3) {
      for (int j = 0; j < 9; j += 3) {
        int cnt = 0;
        for (int k = 0; k < 9; k++) {
          int ny = i + dy[k], nx = j + dx[k];
          cnt += a[ny][nx] == d;
        }
        if (cnt == 1) continue;
        for (int k = 0; k < 9; k++) {
          int ny = i + dy[k], nx = j + dx[k];
          if (a[ny][nx] == d) wa[ny][nx] = 1;
        }
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      cout << " *"[wa[i][j]] << a[i][j];
    }
    cout << endl;
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    if (i) cout << endl;
    solve();
  }

  return 0;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
bool maze[9][9];
void tate(vector<string> s){
  /*
  cout<<"tate"<<endl;
  rep(i,9){
    rep(j,9)
      cout<<s[j][i]<<" ";
    cout<<endl;
  }
  //*/
  rep(i,9){
    //cout<<i<<endl;
    int used[9] = {0};
    rep(j,9){
      used[s[j][i]-'1']++;
    }
    rep(j,9){
      if(used[j] > 1){
	rep(k,9){
	  if(s[k][i] == j + '1')maze[k][i] = false;
	}
      }
    }
  }  
}

void yoko(vector<string> s){
  rep(i,9){
    //cout<<i<<endl;
    int used[9] = {0};
    rep(j,9){
      used[s[i][j]-'1']++;
    }
    rep(j,9){
      if(used[j] > 1){
	rep(k,9){
	  if(s[i][k] == j + '1')maze[i][k] = false;
	}
      }
    }
  }    
}

void masu(vector<string> s){
  rep(i,3){
    rep(j,3){
      int used[9] = {0};
      rep(k,3){
	rep(l,3){
	  used[s[i*3+k][j*3+l] - '1'] ++;
	}
      }
      
      rep(k,3){
	rep(l,3){
	  int x = i * 3 + k, y =  j * 3 + l;
	  
	  if(used[s[x][y] -'1'] >1)
	  if(s[x][y] == j + '1')maze[x][y] = false;
	}
      }
      
    }
  }
}

int main(void){
  int n;
  cin>>n;
  while(n--){
    vector<string> s;
    rep(i,9){
      string str;
      rep(j,9){
	maze[i][j] = true;
	string ss;
	cin>>ss;
	str += ss;
      }
      s.push_back(str);
    }
    cout<<endl;
    
    tate(s);
    yoko(s);
    masu(s);
    rep(i,9){
      rep(j,9){
	if(maze[i][j])cout<<" ";
	else cout<<"*";
	cout<<s[i][j];
      }
      cout<<endl;
    }
    
  }
}

C++: #include<cstdio>

using namespace std;

int pazzle[16][16];
bool check[16][16];

int main(void){
	int n;
	while(scanf("%d", &n) != EOF){
		while(n-- > 0){
			
			//ツ渉可甘コツ可サ
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					check[i][j] = false;
				}
			}
			
			//ツパツズツδ仰づ個禿偲ヲ
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					scanf("%d", &pazzle[i][j]);
				}
			}
			
			//ツ可。ツ板サツ津ィ
			for(int i = 0; i < 9; i++){
				for(int j= 0; j < 9; j++){
					for(int k = j+1; k < 9; k++){
						if(pazzle[i][j] == pazzle[i][k]){
							check[i][j] = true;
							check[i][k] = true;
						}
					}
				}
			}
			
			//ツ縦ツ板サツ津ィ
			for(int i = 0; i < 9; i++){
				for(int j= 0; j < 9; j++){
					for(int k = j+1; k < 9; k++){
						if(pazzle[j][i] == pazzle[k][i]){
							check[j][i] = true;
							check[k][i] = true;
						}
					}
				}
			}
			
			//3*3ツ板サツ津ィ
			int temp[9];
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					for(int k = j+1; k < 9; k++){
						if(pazzle[3*i/3+j/3][3*i%3+j%3] == pazzle[3*i/3+k/3][3*i%3+k%3]){
							check[3*i/3+j/3][3*i%3+j%3];
							check[3*i/3+k/3][3*i%3+k%3];
						}
					}
				}
			}
							
			
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					printf("%c%d", check[i][j]?'*':' ',pazzle[i][j]);
				}puts("");
			}
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
long n,i,j,k,c[9][9],a[9];
string b[9];
cin>>n;
for(k=0;k<n;k++){
if(k>0)cout<<endl;
for(i=0;i<9;i++)
for(j=0;j<9;j++)cin>>c[i][j];
for(i=0;i<9;i++)b[i]="         ";
for(i=0;i<9;i++){
for(j=0;j<9;j++)a[j]=0;
for(j=0;j<9;j++)a[c[i][j]-1]++;
for(j=0;j<9;j++)if(a[c[i][j]-1]>1)b[i][j]='*';
}
for(i=0;i<9;i++){
for(j=0;j<9;j++)a[j]=0;
for(j=0;j<9;j++)a[c[j][i]-1]++;
for(j=0;j<9;j++)if(a[c[j][i]-1]>1)b[j][i]='*';
}
for(i=0;i<9;i++){
for(j=0;j<9;j++)a[j]=0;
for(j=0;j<9;j++)a[c[i/3*3+j/3][(i*3)%9+j%3]-1]++;
for(j=0;j<9;j++)if(a[c[i/3*3+j/3][(i*3)%9+j%3]-1]>1)b[i/3*3+j/3][(i*3)%9+j%3]='*';
}
for(i=0;i<9;i++){
for(j=0;j<9;j++)cout<<b[i][j]<<c[i][j];
cout<<endl;
}
}
return 0;
}