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 <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>

typedef long long ll;

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int puzzle[9][9];
		for (int i = 0; i < 9; ++i)
		{
			for (int j = 0; j < 9; ++j)
			{
				int t;
				scanf("%d", &t);
				puzzle[i][j] = t;
			}
		}

		bool dame[9][9];
		memset(dame, 0, sizeof(dame));
		for (int i = 0; i < 9; ++i)
		{
			vector<pair<int, int> > v[10];
			vector<pair<int, int> > h[10];
			for (int j = 0; j < 9; ++j)
			{
				v[puzzle[j][i]].push_back(make_pair(j, i));
				h[puzzle[i][j]].push_back(make_pair(i, j));
			}
			for (int j = 1; j < 10; ++j)
			{
				if (v[j].size() > 1)
					for (int k = 0; k < v[j].size(); ++k)
						dame[v[j][k].first][v[j][k].second] = true;
				if (h[j].size() > 1)
					for (int k = 0; k < h[j].size(); ++k)
						dame[h[j][k].first][h[j][k].second] = true;
			}
		}

		for (int i = 0; i < 3; ++i)
		{
			for (int j = 0; j < 3; ++j)
			{
				vector<pair<int, int> > c[10];
				for (int k = 0; k < 3; ++k)
				{
					for (int l = 0; l < 3; ++l)
					{
						int ty = i*3 + k;
						int tx = j*3 + l;
						c[puzzle[ty][tx]].push_back(make_pair(ty, tx));
					}
				}
				for (int k = 1; k < 10; ++k)
					if (c[k].size() > 1)
						for (int l = 0; l < c[k].size(); ++l)
							dame[c[k][l].first][c[k][l].second] = true;
			}
		}

		for (int i = 0; i < 9; ++i)
		{
			for (int j = 0; j < 9; ++j)
				printf("%c%d", dame[i][j] ? '*' : ' ', puzzle[i][j]);
			printf("\n");
		}
		if (n)
			printf("\n");
	}
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair

int main(){
  int fld[9][9];
  bool num[10],fldb[9][9];
  int n;
  cin>>n;
  for(int times=0;times<n;times++){
    if(times!=0)cout<<endl;
    memset(fldb,true,sizeof(fldb));
    REP(i,9)REP(j,9)cin>>fld[j][i];
    REP(i,9){
      memset(num,false,sizeof(num));
      REP(j,9)if(num[fld[i][j]]){
        int l=fld[i][j];
        REP(k,9)if(fld[i][k]==l)fldb[i][k]=false;
      }else num[fld[i][j]]=true;
    }
    REP(i,9){
      memset(num,false,sizeof(num));
      REP(j,9)if(num[fld[j][i]]){
        int l=fld[j][i];
        REP(k,9)if(fld[k][i]==l)fldb[k][i]=false;
      }else num[fld[j][i]]=true;
    }
    REP(i,3)REP(j,3){
      memset(num,false,sizeof(num));
      REP(x,3)REP(y,3){
        int nx=i*3+x,ny=j*3+y;
        if(num[fld[nx][ny]]){
          REP(o,3)REP(p,3)if(fld[o][p]==fld[nx][ny])fldb[o][p]=false;
        }else num[fld[nx][ny]]=true;
      }
    }
    REP(i,9){
      REP(j,9){
        if(fldb[j][i])cout<<" "<<fld[j][i];
        else cout<<"*"<<fld[j][i];
      }
      cout<<endl;
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n; scanf("%d%*c", &n);
	rep(I, n) {
		string s[9];
		rep(i, 9) {
			getline(cin, s[i]);
			s[i] = ' ' + s[i];
		}
		rep(i, 9) {
			int cnt[9]{};
			for (int j = 1; j < s[i].size(); j += 2)
				cnt[s[i][j] - '1']++;
			for (int j = 0; j < s[i].size(); j += 2) {
				if (cnt[s[i][j + 1] - '1'] > 1)s[i][j] = '*';
			}
		}
		for (int i = 1; i < s[0].size(); i += 2) {
			int cnt[9]{};
			rep(j, 9)
				cnt[s[j][i] - '1']++;
			rep(j, 9) {
				if (cnt[s[j][i] - '1'] > 1)s[j][i - 1] = '*';
			}
		}
		for (int i = 1; i < s[0].size(); i += 6) {
			for (int j = 0; j < 9; j += 3) {
				int cnt[9]{};
				rep(t, 3)for (int k = 0; k < 6; k += 2) {
					cnt[s[j + t][i + k] - '1']++;
				}
				rep(t, 3)for (int k = 0; k < 6; k += 2) {
					if (cnt[s[j + t][i + k] - '1'] > 1) {
						s[j + t][i + k - 1] = '*';
					}
				}
			}
		}
		rep(i, 9) {
			cout << s[i] << endl;
		}
		if (I != n - 1)cout << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int math[9][9], jud[10] = {};
bool 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] = 1;
				mmath[jud2[math[i][j]][0]][jud2[math[i][j]][1]] = 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] = 1;
					mmath[i][jud[math[i][j]]] = 1;
				}
				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] = 1;
					mmath[jud[math[j][i]]][i] = 1;
				}
				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++){
				if(!mmath[i][j])
					cout << ' ';
				else
					cout << '*';
				cout << math[i][j];
			}
			cout << endl;
		}
		if(k != n - 1)
			cout << endl;
	}
}