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<cstdio>
#include<string>
#include<queue>
#include<unordered_map>
#include<map>
#include<vector>
#define P pair<int,int>
using namespace std;

int main()
{
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		if (b)cout << endl;
		bool k[9][9]{};
		int c[9][9];
		for (int d = 0; d < 9; d++) {
			for (int e = 0; e < 9; e++) {
				cin >> c[d][e];
			}
		}
		for (int f = 0; f < 9; f++) {
			vector<P>h[10];
			for (int g = 0; g < 9; g++) {
				h[c[f][g]].push_back(P(f, g));
			}
			for (auto i : h) {
				if (i.size() > 1) {
					for (P j : i) {
						k[j.first][j.second] = true;
					}
				}
			}
		}
		for (int f = 0; f < 9; f++) {
			vector<P>h[10];
			for (int g = 0; g < 9; g++) {
				h[c[g][f]].push_back(P(g, f));
			}
			for (auto i : h) {
				if (i.size() > 1) {
					for (P j : i) {
						k[j.first][j.second] = true;
					}
				}
			}
		}
		for (int f = 0; f < 3; f++) {
			for (int g = 0; g < 3; g++) {
				vector<P>h[10];
				for (int k = 0; k < 3; k++) {
					for (int l = 0; l < 3; l++) {
						h[c[f * 3 + k][g * 3 + l]].push_back(P(f*3+k,g*3+l));
					}
				}
				for (auto i : h) {
					if (i.size() > 1) {
						for (P j : i) {
							k[j.first][j.second] = true;
						}
					}
				}
			}
		}
		for (int x = 0; x < 9; x++) {
			for (int y = 0; y < 9; y++) {
				if (k[x][y])cout << '*';
				else cout << ' ';
				cout << c[x][y];
			}
			cout << endl;
		}
	}
}

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[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++) {
			for (int k = 0; k < 9; k++) {
				if (a[j][k] == true) {
					cout << '*';
				}
				else {
					cout << ' ';
				}
				cout << x[j][k];
			}
			cout << endl;
		}
	}
}

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 < 10; 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 < 10; 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++: # define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
# include <unordered_map>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 

int main()
{
	int n; cin >> n;
	bool f = false;
	while (n--)
	{
		if (f)cout << endl;
		f = true;
		int a[9][9];
		bool b[9][9];
		for (int i = 0; i < 9; i++)
		{
			for (int j = 0; j < 9; j++)
			{
				cin >> a[i][j];
				b[i][j] = false;
			}
		}
		for (int i = 0; i < 9; i++)
		{
			for (int j = 0; j < 9; j++)
			{


				for (int k = 0; k < 9; k++)
				{
					if (k == j)continue;
					if (a[i][j] == a[i][k])
					{
						b[i][j] = true;
						b[i][k] = true;
					}
					if (a[j][i] == a[k][i])
					{
						b[j][i] = true;
						b[k][i] = true;
					}
				}
				if (i % 3 == 0 && j % 3 == 0)
				{
					for (int k = 0; k < 9; k++)
					{
						for (int l = 0; l < 9; l++)
						{
							if (i + k % 3 == i + l % 3 || j + k / 3 == j + l / 3)continue;
							if (a[i + k % 3][j + k / 3] == a[i + l % 3][j + l / 3])
							{
								b[i + k % 3][j + k / 3] = true;
								b[i + l % 3][j + l / 3] = true;
							}
						}
					}
				}

			}
		}

		for (int i = 0; i < 9; i++)
		{
			for (int j = 0; j < 9; j++)
			{
				cout << (b[i][j] ? '*' : ' ');
				cout << a[i][j];
			}
			cout << endl;
		}
	}


}