Go: package main

import (
	"bufio"
		"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)
	for 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>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <vector>
#include <sstream>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

void cnc(int q[9], int ct[10]){
	rep(i,10) ct[i] = 0;
	rep(i,9) ct[q[i]]++;
}

int main(void){

  int n;
	int st[9][2] ={{0,0},{0,3},{0,6},{3,0},{3,3},{3,6},{6,0},{6,3},{6,6}};
	while(cin >> n){
		bool kg=false;
		if(cin.eof()) break;
		int w[9][9]={0};
		
		rep(i,n){
			if(kg) cout << endl;
			rep(j,9) rep(k,9) cin >> w[j][k];
			int wk[9]={0}, wt[10]={0};
			bool rr[9][9]={false};
			rep(j,9){
				rep(k,9) wk[k] = w[j][k];
				cnc(wk,wt);
				rep(k,9) if(wt[w[j][k]] > 1) rr[j][k]=true;

				rep(k,9) wk[k] = w[k][j];
				cnc(wk,wt);
				rep(k,9) if(wt[w[k][j]] > 1) rr[k][j]=true;

				rep(k,9) wk[k] = w[st[j][0]+k/3][st[j][1]+k%3];
				cnc(wk,wt);
				rep(k,9) if(wt[w[st[j][0]+k/3][st[j][1]+k%3]] > 1) rr[st[j][0]+k/3][st[j][1]+k%3]=true;
			}
			rep(j,9) rep(k,9){
				cout << (rr[j][k]? "*": " ");
				cout << w[j][k];
				cout << (k>7? "\n": "");
			}
			kg=true;
		}
	}
	return 0;
	
}

C++: #include<stdio.h>
int table[9][9];
bool NG[9][9];
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
				scanf("%d",&table[i][j]);
		for(int i=0;i<9;i++)
			for(int j=0;j<9;j++)
				NG[i][j]=false;
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				bool ok=true;
				for(int k=0;k<9;k++){
					if(table[i][j]==table[i][k]&&j!=k)ok=false;
				}
				for(int k=0;k<9;k++){
					if(table[i][j]==table[k][j]&&i!=k)ok=false;
				}
				int seci=i/3;
				int secj=j/3;
				for(int k=0;k<3;k++){
					for(int 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)NG[i][j]=true;
			}
		}
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				printf(NG[i][j]?"*":" ");
				printf("%d",table[i][j]);
			}
			printf("\n");
		}
		if(a)printf("\n");
	}
}

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

int main(){
	int n;
	cin >> n;
	// input
	for( int t = 0; t < n; t++ ){
		int puzzle[9][9];
		int row[9][9] = {{0}}, col[9][9] = {{0}}, rect[9][9] = {{0}};
		for( int i = 0; i < 9; i++ ){
			for( int j = 0; j < 9; j++ ){
				cin >> puzzle[i][j];
				if( row[i][puzzle[i][j]-1] == 1 ) row[i][puzzle[i][j]-1] = -1;
				else row[i][puzzle[i][j]-1] = 1;
				if( col[j][puzzle[i][j]-1] == 1 ) col[j][puzzle[i][j]-1] = -1;
				else col[j][puzzle[i][j]-1] = 1;
				if( rect[i/3*3+j/3][puzzle[i][j]-1] == 1 ) rect[i/3*3+j/3][puzzle[i][j]-1] = -1;
				else rect[i/3*3+j/3][puzzle[i][j]-1] = 1;
			}
		}

		// output
		if( t != 0 ) cout << endl;
		for( int i = 0; i < 9; i++ ){
			for( int j = 0; j < 9; j++ ){
				if( row[i][puzzle[i][j]-1] == -1 || col[j][puzzle[i][j]-1] == -1 || rect[i/3+j/3][puzzle[i][j]-1] == -1 ) cout << "*";
				else cout << " ";
				cout << puzzle[i][j];
			}
			cout << endl;
		}
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;


int main(){
  int n; cin>>n;
  int cc = 0;
  while(n --> 0){
    int  b[9][9];
    bool f[9][9];
    if(cc++ != 0) puts("");
    REP(i,9) REP(j,9){
      cin>>b[i][j];
      f[i][j] = true;
    }
    for(int y = 0; y<9; y+=3){
      for(int x = 0; x<9; x+=3){
        int cnt[10] = {0};
        REP(i,3) REP(j,3)
          cnt[b[y+i][x+j]]++;
        REP(i,3) REP(j,3)
          if(cnt[b[y+i][x+j]] != 1){
            f[y+i][x+j] = false;
          }
      }
    }
    REP(y,9){
      int cnt[10] = {0};
      REP(x,9)
        cnt[b[y][x]]++;
      REP(x,9)
        if(cnt[b[y][x]] != 1)
          f[y][x] = false;
    }
    REP(x,9){
      int cnt[10] = {0};
      REP(y,9)
        cnt[b[y][x]]++;
      REP(y,9)
        if(cnt[b[y][x]] != 1)
          f[y][x] = false;
    }

    REP(i,9){
      REP(j,9)
        printf("%c%d",(f[i][j]?' ':'*'),b[i][j]);
      puts("");
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int ma[9][9];

void solve(int y, int x, int check[][9]){
    rep(i, 9){
        if(ma[i][x] == ma[y][x]) check[i][x]++;
        if(ma[y][i] == ma[y][x]) check[y][i]++;
    }
    rep(i, 3){
        rep(j, 3){
            if(ma[i + y / 3 * 3][j + x / 3 * 3] == ma[y][x])
                check[i + y / 3 * 3][j + x / 3 * 3]++;
        }
    }
}

int main(){
    int n;
    while(cin >> n){
        rep(i, n){
            if(i) cout << endl;
            int check[9][9] = {0};
            rep(i, 9){
                rep(j, 9){
                    cin >> ma[i][j];
                }
            }
            rep(i, 9){
                rep(j, 9){
                    solve(i, j, check);
                }
            }
            rep(i,9){
                rep(j,9){
                    if(check[i][j] > 3)
                        cout << '*';
                    else
                        cout << ' ';
                    cout << ma[i][j];
                }
                cout << endl;
            }
        }
    }
}