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 <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

struct Data{
	Data(){
		index = 0;
	}
	void add(int data){
		wrong_data[index] = data;
		index++;
	}

	int wrong_data[10],index;
};

int main(){

	int n,table[10][10],check[10][10];
	Data tmp_check[10];

	scanf("%d",&n);

	for(int i = 0; i < n; i++){

		for(int k = 1; k <= 9; k++){
			for(int p = 1; p <= 9; p++){
				scanf("%d",&table[k][p]);
				check[k][p] = 0;
			}
		}

		for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;


		for(int col = 1; col <= 9; col++){
			for(int row = 1; row <= 9; row++){
				tmp_check[table[row][col]].add(row);
			}

			for(int k = 1; k <= 9; k++){
				if(tmp_check[k].index > 1){
					for(int p = 0; p < tmp_check[k].index; p++){
						check[tmp_check[k].wrong_data[p]][col]++;
					}
				}
			}

			for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;
		}

		for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;

		for(int row = 1; row <= 9; row++){
			for(int col = 1; col <= 9; col++){
				tmp_check[table[row][col]].add(col);
			}

			for(int k = 1; k <= 9; k++){
				if(tmp_check[k].index > 1){
					for(int p = 0; p < tmp_check[k].index; p++){
						check[row][tmp_check[k].wrong_data[p]]++;
					}
				}
			}

			for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;
		}

		for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;


		for(int row = 1; row <= 7; row+= 3){
			for(int col = 1; col <= 7; col += 3){

				for(int k = 0; k < 3; k++){
					for(int p = 0; p < 3; p++){
						tmp_check[table[row+k][col+p]].add(10*(row+k)+col+p);
					}
				}

				for(int k = 1; k <= 9; k++){
					if(tmp_check[k].index > 1){
						for(int p = 0; p < tmp_check[k].index; p++){
							check[tmp_check[k].wrong_data[p]/10][tmp_check[k].wrong_data[p]%10]++;
						}
					}
				}

				for(int k = 1; k <= 9; k++)tmp_check[k].index = 0;
			}
		}

		if(i > 0)printf("\n");

		for(int row = 1; row <= 9; row++){
			for(int col = 1; col <= 9; col++){
				if(check[row][col] >= 1){
					printf("*%d",table[row][col]);
				}else{
					printf(" %d",table[row][col]);
				}
			}
			printf("\n");
		}

	}

    return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (int)(count); i++)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
const int MODULO = 100000 ;
const int INF = 100000000; //1e8

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef complex<double> Cd;

using namespace std;

int main()
{
	int t; cin>>t;
	bool nl = false;
	while(t--){
		int a[9][9]; FOR(i,9)FOR(j,9) cin>>a[i][j];
		bool b[9][9] = {};
		FOR(i,3)FOR(j,3){
			int b2[10] ={};
			FOR(k,3)FOR(l,3) b2[a[i*3+k][j*3+l]]++;
			FOR(k,10) if(b2[k] >= 2){
				FOR(l,3)FOR(m,3)
					if(a[i*3+l][j*3+m] == k) b[i*3+l][j*3+m] = true;
			}
		}
		FOR(i,9){
			int b2[10] ={};
			FOR(j,9) b2[a[i][j]]++;
			FOR(k,10) if(b2[k] >= 2){
				FOR(j,9) if(a[i][j] == k) b[i][j] = true;
			}
		}
		FOR(j,9){
			int b2[10] ={};
			FOR(i,9) b2[a[i][j]]++;
			FOR(k,10) if(b2[k] >= 2){
				FOR(i,9) if(a[i][j] == k) b[i][j] = true;
			}
		}

		if(nl) puts("");
		nl = true;
		FOR(i,9){
			FOR(j,9) printf("%c%d",b[i][j]?'*':' ',a[i][j]);
			puts("");
		}
	}
	return 0;
}

C++: #include<cstdio>
using namespace std;
int main(){
  int n,m[9][9];
  char c[9][9];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    
    for(int j=0;j<9;j++){
      for(int k=0;k<9;k++){
	scanf("%d",&m[j][k]);
	c[j][k] = ' ';
      }
    }
    int dx[9] = {0,1,2,0,1,2,0,1,2};
    int dy[9] = {0,0,0,1,1,1,2,2,2};
    for(int l=0;l<9;l++){
      for(int j=0;j<8;j++){
	for(int k = j+1;k<9;k++){
	  if(m[l][j] == m[l][k]){
	    c[l][j] = '*';
	    c[l][k] = '*';
	  }
	  if(m[j][l] == m[k][l]){
	    c[j][l] = '*';
	    c[k][l] = '*';
	  }
	}
      }
    }
    
    for(int j=0;j<=6;j+=3){
      for(int k=0;k<=6;k+=3){
	for(int l=0;l<8;l++){
	  for(int o=l+1;o<9;o++){
	    if(m[j+ dy[l]][k+ dx[l]] == m[j+ dy[o]][k+ dx[o]]){
	      c[j+ dy[l]][k+ dx[l]] = '*';
	      c[j+ dy[o]][k+ dx[o]] = '*';
	    }
	  }
	}
      }
    }

    for(int j=0;j<9;j++){
      for(int k=0;k<9;k++){
	printf("%c%d",c[j][k],m[j][k]);
      }
      putchar('\n');
    }

  }
  return (0);
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	bool r=false;
	while(n--){
	if(r)cout<<endl;
	r=true;
	int a[9][9];
	bool d[9][9]={0};
	for(int i=0;i<9;i++){
		for(int j=0;j<9;j++){
			cin>>a[i][j];
			a[i][j]--;
		}
	}
	int t[9];
	for(int i=0;i<9;i++){
		for(int j=0;j<9;j++)t[j]=0;
		for(int j=0;j<9;j++)t[a[i][j]]++;
		for(int j=0;j<9;j++)if(t[j]>1)for(int k=0;k<9;k++)if(a[i][k]==j)d[i][k]=true;
	}
	for(int i=0;i<9;i++){
		for(int j=0;j<9;j++)t[j]=0;
		for(int j=0;j<9;j++)t[a[j][i]]++;
		for(int j=0;j<9;j++)if(t[j]>1)for(int k=0;k<9;k++)if(a[k][i]==j)d[k][i]=true;
	}
	for(int f=0;f<9;f+=3){
		for(int g=0;g<9;g+=3){
			for(int i=0;i<9;i++)t[i]=0;
			for(int i=0;i<3;i++)for(int j=0;j<3;j++)t[a[i+f][j+g]]++;
			for(int k=0;k<9;k++)if(t[k]>1){
				for(int i=0;i<3;i++)for(int j=0;j<3;j++){
					if(a[i+f][j+g]==k)d[i+f][j+g]=true;
				}
			}
		}
	}
	for(int i=0;i<9;i++){
		for(int j=0;j<9;j++){
			if(d[i][j])cout<<"*";
			else cout<<" ";
			cout<<a[i][j]+1;
		}
		cout<<endl;
	}
	}
	return 0;
}