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<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){
    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){
	  int x = i * 3 + k, y =  j * 3 + l;
	  //cout<<x<<" "<<y<<" ";
	  used[s[x][y] - '1'] ++;
	}
	//cout<<endl;
      }
      //cout<<endl<<endl;;
      
      //rep(k,9)cout<<used[k]<<" ";cout<<endl;
      rep(k,3){
	rep(l,3){
	  
	  int x = i * 3 + k, y =  j * 3 + l;
	  //cout<<s[x][y]<<" "<<used[s[x][y]-'1']<< " ";
	  if(used[s[x][y] -'1'] >1)
	    maze[x][y] = false;
	    //if(s[x][y] ==  + '1')maze[x][y] = false;
	}
	//	cout<<endl;
      }
      //    cout<<endl;
      
    }
  }
}

int main(void){
  int n;
  cin>>n;
  rep(z,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);
    }
    if(z)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<iostream>
#include<cstring>
using namespace std;
int x[9][9], n, s[9], cnt[9], p[9][9]; bool a[9][9];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		memset(x, 0, sizeof(x));
		memset(p, 0, sizeof(p));
		memset(a, false, sizeof(a));
		memset(cnt, 0, sizeof(cnt));
		if (n) { cout << endl; }
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				cin >> x[9][9];
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[j][k]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[j][k]] >= 2) {
					a[j][k] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[k][j]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[k][j]] >= 2) {
					a[k][j] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				p[(j / 3) * 3 + (k / 3)][cnt[(j / 3) * 3 + (k / 3)]] = x[j][k];
				cnt[(j / 3) * 3 + (k / 3)]++;
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[j][k]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[j][k]] >= 2) {
					a[j][k] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				if (a[j][k] == true) {
					cout << '*';
				}
				else {
					cout << ' ';
				}
				cout << x[j][k];
			}
			cout << endl;
		}
	}
}

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

int main(){
  int i,j,k,l,n,a[9][9],ans[9][9],c=0;
  while(cin >> n){
    for(i=0;i<n;i++){

      if(c) cout << endl;
      c = 1;

      for(j=0;j<9;j++){
	for(k=0;k<9;k++){
	  cin >> a[j][k];
	  ans[j][k] = 0;
	}
      }

      for(j=0;j<9;j++){
	for(k=0;k<9;k++){
	  for(l=k+1;l<9;l++){
	    if(a[j][k] == a[j][l]) ans[j][k] = ans[j][l] = 1;
	    if(a[k][j] == a[l][j]) ans[k][j] = ans[l][j] = 1;
	  }
	}
      }

      for(j=0;j<=6;j+=3){
	for(int m=0;m<=6;m+=3){
	  for(k=0;k<9;k++){
	    for(l=k+1;l<9;l++){
	      if(a[k/3+j][k%3+m] == a[l/3+j][l%3+m]) ans[k/3+j][k%3+m] = ans[l/3+j][l%3+m] = 1;
	    }
	  }
	}
      }

      for(j=0;j<9;j++){
	for(k=0;k<9;k++){
	  if(ans[j][k]) cout << "*" << a[j][k];
	  else cout << " " << a[j][k];
	}
	cout << endl;
      }

    }
  }
  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;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int x[9][9], n, s[10], cnt[10], p[9][9]; bool a[9][9];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		memset(x, 0, sizeof(x));
		memset(p, 0, sizeof(p));
		memset(a, false, sizeof(a));
		memset(cnt, 0, sizeof(cnt));
		if (i) { cout << endl; }
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				cin >> x[j][k];
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[j][k]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[j][k]] >= 2) {
					a[j][k] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[x[k][j]]++;
			}
			for (int k = 0; k < 9; k++) {
				if (s[x[k][j]] >= 2) {
					a[k][j] = true;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				p[(j / 3) * 3 + (k / 3)][cnt[(j / 3) * 3 + (k / 3)]] = x[j][k];
				cnt[(j / 3) * 3 + (k / 3)]++;
			}
		}
		for (int j = 0; j < 9; j++) {
			memset(s, 0, sizeof(s));
			for (int k = 0; k < 9; k++) {
				s[p[j][k]]++;
			}
			for (int k = 0; k < 10; k++) {
				if (s[p[j][k]] >= 2) {
					for (int l = 0; l < 9; l++) {
						if (x[j][k] == p[j][k]) {
							a[j][k] = true;
						}
					}
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				if (a[j][k] == true) {
					cout << '*';
				}
				else {
					cout << ' ';
				}
				cout << x[j][k];
			}
			cout << endl;
		}
	}
}