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 <algorithm>
using namespace std;
int math[9][9], jud[10] = {};
char mmath[9][9];
void jj(int x, int y){
	int jud2[10][2];
	for(int i = 0; i < 10; i++){
		fill(jud2[i], jud2[i] + 2, -1);
	}
	for(int i = x; i < x + 3; i++){
		for(int j = y; j < y + 3; j++){
			if(jud2[math[i][j]][0] >= 0){
				mmath[i][j] = '*';
				mmath[jud2[math[i][j]][0]][jud2[math[i][j]][1]] = '*';
			}
			jud2[math[i][j]][0] = i;
			jud2[math[i][j]][1] = j;
		}
	}
}
int main(){
	int n;
	cin >> n;
	for(int k = 0; k < n; k++){
		for(int i = 0; i < 9; i++)
			fill(mmath[i], mmath[i] + 9, 0);
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				cin >> math[i][j];
			}
		}
		for(int i = 0; i < 9; i++){
			fill(jud, jud + 10, -1);
			for(int j = 0; j < 9; j++){
				if(jud[math[i][j]] >= 0){
					mmath[i][j] = '*';
					mmath[i][jud[math[i][j]]] = '*';
				}
				jud[math[i][j]] = j;
			}
		}
		for(int i = 0; i < 9; i++){
			fill(jud, jud + 10, -1);
			for(int j = 0; j < 9; j++){
				if(jud[math[j][i]] >= 0){
					mmath[j][i] = '*';
					mmath[jud[math[j][i]]][i] = '*';
				}
				jud[math[j][i]] = j;
			}
		}
		jj(0, 0);	jj(3, 0);	jj(6, 0);
		jj(0, 3);	jj(3, 3);	jj(6, 3);
		jj(0, 6);	jj(3, 6);	jj(6, 6);
		for(int i = 0; i < 9; i++){
			for(int j = 0; j < 9; j++){
				cout<< mmath[i][j] << math[i][j];
			}
			cout << endl;
		}
		cout << endl;
	}
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	int n;
	cin>>n;
	rep(loop,n){
		if(loop>0)
			cout<<endl;
		
		vvi a(9,vi(9));
		rep(i,9) rep(j,9)
			cin>>a[i][j];
		
		vvi bad(9,vi(9));
		rep(i,9){
			vi hist(10);
			rep(j,9)
				hist[a[i][j]]++;
			rep(j,9)
				if(hist[a[i][j]]!=1)
					bad[i][j]=1;
			hist=vi(10);
			rep(j,9)
				hist[a[j][i]]++;
			rep(j,9)
				if(hist[a[j][i]]!=1)
					bad[j][i]=1;
		}
		rep(k,9){
			int offi=k/3*3,offj=k%3*3;
			vi hist(10);
			rep(i,3) rep(j,3)
				hist[a[offi+i][offj+j]]++;
			rep(i,3) rep(j,3)
				if(hist[a[offi+i][offj+j]]!=1)
					bad[offi+i][offj+j]=1;
		}
		rep(i,9){
			rep(j,9)
				cout<<(bad[i][j]?'*':' ')<<a[i][j];
			cout<<endl;
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <string.h>

using namespace std;
const int N = 9;
void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		char Field[N][N];
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				cin >> Field[i][j];
			}
		}
		bool Flag[N][N];
		memset(Flag, 1, sizeof(Flag));
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				if(Flag[i][j])
				{
					for(int a = 0; a < N; ++a)
					{
						if(i != a && Field[a][j] == Field[i][j])
						{
							Flag[i][j] = Flag[a][j] = false;
						}
					}
					for(int a = 0; a < N; ++a)
					{
						if(j != a && Field[i][a] == Field[i][j])
						{
							Flag[i][j] = Flag[i][a] = false;
						}
					}
					int x = j / 3;
					x *= 3;
					int y = i / 3;
					y *= 3;
					for(int a = x; a < x + 3; ++a)
					{
						for(int b = y; b < y + 3; ++b)
						{
							if(a != j && b != i && Field[b][a] == Field[i][j])
							{
								Flag[b][a] = Flag[i][j] = false;
							}
						}
					}
				}
			}
		}
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				if(Flag[i][j] == false)
				{
					cout << '*';
				}
				else
				{
					cout << ' ';
				}
				cout << Field[i][j];
			}
			cout << endl;
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
#include <cstring>
#define rep(i,n) for(int i = 0 ; i < n ; i++)

using namespace std;

int puzzle[9][9];

void field(int x,int &to,int &from){
  if(0 <= x && x < 3){
    to = 0;
    from = 2;
  }else if(3 <= x && x < 6){
    to = 3;
    from = 6;
  }else{
    to = 7;
    from = 9;
  }
}

bool check1(int x,int y){
  for(int i = x-1 ; i >= 0 ; i--){
    if(puzzle[x][y] == puzzle[i][y]) return false;
  }
  for(int i = x+1 ; i < 9 ; i++){
    if(puzzle[x][y] == puzzle[i][y]) return false;
  }

  return true;
}

bool check2(int x,int y){
  for(int i = y-1 ; i >= 0 ; i--){
    if(puzzle[x][y] == puzzle[x][i]) return false;
  }
  for(int i = y+1 ; i < 9 ; i++){
    if(puzzle[x][y] == puzzle[x][i]) return false;
  }

  return true;
}

bool check3(int x,int y){
  int sx,tx,sy,ty;

  field(x,sx,tx);
  field(y,sy,ty);

  for(int i = sx ; i < tx ; i++){
    for(int j = sy ; j < ty ; j++){
      if(x == i && y == j) continue;
      if(puzzle[x][y] == puzzle[i][j]) return false;
    }
  }

  return true;
}

int main(){
  int T;

  cin >> T;
  rep(t,T){
    if(t) cout << endl;

    rep(i,9){
      rep(j,9){
	cin >> puzzle[i][j];
      }
    }

    char ch[9][9];
    rep(i,9){
      rep(j,9){
	ch[i][j] = ' ';
      }
    }

    rep(i,9){
      rep(j,9){
	if(check1(i,j) && check2(i,j) && check3(i,j)) continue;
	ch[i][j] = '*';
      }
    }

    rep(i,9){
      rep(j,9){
	cout << ch[i][j] << puzzle[i][j];
      }
      cout << endl;
    }
  }

  return 0;
}