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<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int c[9][9];
int data[9][9];


void check_1(){
  int appear[10];
  for(int i = 0; i < 9; i++){
    fill(appear,appear+10,0);
    for(int j = 0; j < 9; j++)
      appear[data[i][j]]++;
    for(int k = 0; k < 9; k++)
      if(appear[data[i][k]] > 1) c[i][k] = 1; 
  }
}

void check_2(){
  int appear[10];
  for(int i = 0; i < 9; i++){
    fill(appear,appear+10,0);
    for(int j = 0; j < 9; j++)
      appear[data[j][i]]++;
    for(int k = 0; k < 9; k++)
      if(appear[data[k][i]] > 1) c[k][i] = 1; 
  }
}

void check_3(){
  int appear[10];
  
  for(int STx = 0; STx < 9; STx+=3)
    for(int STy = 0; STy < 9; STy+=3){
      fill(appear,appear+10,0);
      for(int i = STx; i < STx+3; i++)
	for(int j = STy; j < STy+3; j++)
	  appear[data[i][j]]++;

      for(int i = STx; i < STx+3; i++)
	for(int j = STy; j < STy+3; j++)
	  if(appear[data[i][j]] > 1) c[i][j] = 1;
    }    
}

void print(){
  for(int i = 0; i < 9; i++){
    for(int j = 0; j < 9; j++){
      if(c[i][j]) cout << "*";
      else cout << " ";
      cout << data[i][j];
    }
    cout << endl;
  }
}

int main(){

  int num;
  cin >> num;
  for(int rev = 0; rev < num; rev++){
    if(rev) cout << endl;
    memset(c,0,sizeof(c));
    for(int i = 0; i < 9; i++)
      for(int j = 0; j < 9; j++)
	cin >> data[i][j];
    
    check_1();
    check_2();
    check_3();
    print();
  }
  return 0; 
}

C++: #include <iostream>

using namespace std;

int main() {

	int n, F, f[9][9], p[9][9];

	cin >> n;
	while(n) {
		if(!F) {
			F=1;
		}
		else {
			cout << endl;
		}
		for(int i=0; i<9; i++) {
			for(int j=0; j<9; j++) {
				f[i][j]=0;
				cin >> p[i][j];
			}
		}

		for(int i=0; i<9; i++) {
			for(int j=0; j<9; j++) {
				for(int k=i; k<9; k++) {
					for(int l=j; l<9; l++) {
						if(p[i][j]==p[k][l]&&(i==k||j==l)&&!(i==k&&j==l)) {
							f[i][j]=f[k][l]=1;
						}
					}
				}
			}
		}

		for(int i=0; i<9; i++) {
			for(int j=0; j<9; j++) {
				int x=(i/3)*3, y=(j/3)*3;
				for(int k=x; k<x+3; k++) {
					for(int l=y; l<y+3; l++) {
						if(p[i][j]==p[k][l]&&!(i==k&&j==l)) {
							f[i][j]=f[k][l]=1;
						}
					}
				}
			}
		}
							
		for(int i=0; i<9; i++) {
			for(int j=0; j<9; j++) {
				if(f[i][j]) {
					cout << "*" << p[i][j];
				}
				else {
					cout << " " << p[i][j];
				}
			}
			cout << endl;
		}
		n--;
	}

	return 0;

}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	int N;
	cin>>N;
	for(int ds=0;ds<N;ds++){
		int fld[9][9];
		int cntX[9][9] = {}, cntY[9][9] = {}, cntA[9][9]={};
		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				cin>>fld[i][j]; fld[i][j]--;
				cntY[i][fld[i][j]]++;
				cntX[j][fld[i][j]]++;
				cntA[(i/3)*3+j/3][fld[i][j]]++;
			}
		}

		for(int i=0;i<9;i++){
			for(int j=0;j<9;j++){
				if(cntY[i][fld[i][j]]>1 || cntX[j][fld[i][j]]>1 ||
				   cntA[(i/3)*3+j/3][fld[i][j]]>1)
					printf("*");
				else printf(" ");
				printf("%d",fld[i][j]+1);
			}puts("");
		}
	}
	return 0;
}

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

int N;
struct Pos {
	int x, y;
};

int main() {
	scanf(" %d", &N);
	bool first = true;
	for(int i = 0; i < N; i++) {
		if(!first) {
			puts("");
		}
		// arr[y][x]
		int arr[9][9];
		bool fail[9][9];
		memset(fail, 0, sizeof fail);

		for(int y = 0; y < 9; y++) {
			for(int x = 0; x < 9; x++) {
				scanf(" %d", &arr[y][x]);
			}
		}
		for(int x = 0; x < 9; x++) {
			int count[10];
			memset(count, 0, sizeof count);
			for(int y = 0; y < 9; y++) {
				count[arr[y][x]]++;
			}
			for(int i = 1; i <= 9; i++) {
				if(count[i] != 1) {
					for(int y = 0; y < 9; y++) {
						if(arr[y][x] == i)
							fail[y][x] = true;
					}
				}
			}
		}

		for(int y = 0; y < 9; y++) {
			int count[10];
			memset(count, 0, sizeof count);
			for(int x = 0; x < 9; x++) {
				count[arr[y][x]]++;
			}
			for(int i = 1; i <= 9; i++) {
				if(count[i] != 1) {
					for(int x = 0; x < 9; x++) {
						if(arr[y][x] == i)
							fail[y][x] = true;
					}
				}
			}
		}

		Pos p[9] = {{1, 1}, {1, 4}, {1, 7}, {4, 1}, {4, 4}, {4, 7}, {7, 1}, {7, 4}, {7, 7}};
		for(int i = 0; i < 9; i++) {
			int cx = p[i].x;
			int cy = p[i].y;
			int count[10];
			memset(count, 0, sizeof count);
			for(int x = -1; x <= 1; x++) {
				for(int y = -1; y <= 1; y++) {
					int nx = cx + x;
					int ny = cy + y;
					count[arr[ny][nx]]++;
				}
			}
			for(int j = 1; j <= 9; j++) {
				if(count[j] != 1) {
					for(int x = -1; x <= 1; x++) {
						for(int y = -1; y <= 1; y++) {
							int nx = cx + x;
							int ny = cy + y;
							if(arr[ny][nx] == j) {
								fail[ny][nx] = true;
							}
						}
					}
				}
			}
		}

		for(int y = 0; y < 9; y++) {
			for(int x = 0; x < 9; x++) {
				putchar(fail[y][x] ? '*' : ' ');
				printf("%d", arr[y][x]);
			}
			puts("");
		}
	}

	return 0;
}