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<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int f[9][9];

signed main(void){
  int i, j, k;
  int(n);
  for(int testcase = 0;testcase < n;testcase++){
    if(testcase != 0)puts("");
    rep(i, 9)rep(j, 9)scanf("%d", &f[i][j]);
    rep(i, 9){
      rep(j, 9){
        bool is = true;
        rep(k, 9){
          if(i != k)if(f[i][j] == f[k][j])is = false;
          if(j != k)if(f[i][j] == f[i][k])is = false;
        }
        if(is)printf(" %d", f[i][j]);
        else printf("*%d", f[i][j]);
      }
      puts("");
    }


//*/

//*/ break;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		if (i != 0) {
			cout << endl << flush;
		}
		int hyou[9][9][2] = {0};
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				cin >> hyou[j][k][0];
			}
		}
		int hantei3[9][9] = {0};
		for (int j = 0; j < 9; j++) {
			int hantei[9] = {0};
			int hantei2[9] = {0};
			int p;
			for (int k = 0; k < 9; k++) { 
				hantei[hyou[j][k][0]-1]++; // yoko
			    hantei2[hyou[k][j][0]-1]++; // tate
				if (0 <= k && k <= 2) {
					if (0 <= j && j <= 2) {
						p = 0;
					} else if (3 <= j && j <= 5) {
						p = 3;
					} else {
						p = 6;
					}
				} else if (3 <= k && k <= 5) {
					if (0 <= j && j <= 2) {
						p = 1;
					} else if (3 <= j && j <= 5) {
						p = 4;
					} else {
						p = 7;
					}
				} else {
					if (0 <= j && j <= 2) {
						p = 2;
					} else if (3 <= j && j <= 5) {
						p = 5;
					} else {
						p = 8;
					}
				}
				hantei[p][hyou[j][k][0]-1]++;
			}
			for (int k = 0; k < 9; k++) {
				if (hantei[hyou[j][k][0]-1] > 1) {
					hyou[j][k][1]++;
				}
				if (hantei2[hyou[k][j][0]-1] > 1) {
					hyou[k][j][1]++;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			int p;
			for (int k = 0; k < 9; k++) { 
				if (0 <= k && k <= 2) {
					if (0 <= j && j <= 2) {
						p = 0;
					} else if (3 <= j && j <= 5) {
						p = 3;
					} else {
						p = 6;
					}
				} else if (3 <= k && k <= 5) {
					if (0 <= j && j <= 2) {
						p = 1;
					} else if (3 <= j && j <= 5) {
						p = 4;
					} else {
						p = 7;
					}
				} else {
					if (0 <= j && j <= 2) {
						p = 2;
					} else if (3 <= j && j <= 5) {
						p = 5;
					} else {
						p = 8;
					}
				}
				if (hantei3[p][hyou[j][k][0]-1] > 1) {
					hyou[j][k][1]++;
				}
			}
		}
		for (int j = 0; j < 9; j++) {
			for (int k = 0; k < 9; k++) {
				if (hyou[j][k][1] > 0) {
					cout << "*" << flush;
				} else {
					cout << " " << flush;
				}
				cout << hyou[j][k][0] << flush;
			}
			cout << endl << flush; 
		}
	}
	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 / 3) * 3 + l / 3][(j / 3) % 3 + l % 3 ] == p[j][k]) {
							a[(j / 3) * 3 + l / 3][(j / 3) % 3 + l % 3] = 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;
		}
	}
}