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 <vector>

struct Freq {
	Freq():vector(10, 0) {};
	Freq operator+(const int &i) const {
		Freq res(*this);
		++res.vector.at(i);
		return res;
	}
	Freq &operator+=(const int &i) {
		++vector.at(i);
		return (*this);
	}
	bool operator&(const int &i) const {
		return (vector.at(i) > 1);
	}
	std::vector<char> vector;
};
static const std::vector<std::pair<int, int>> square{ std::make_pair<int, int>(0, 0), std::make_pair<int, int>(1, 0), std::make_pair<int, int>(2, 0), std::make_pair<int, int>(0, 1), std::make_pair<int, int>(1, 1), std::make_pair<int, int>(2, 1), std::make_pair<int, int>(0, 2), std::make_pair<int, int>(1, 2), std::make_pair<int, int>(2, 2) };
std::vector<std::vector<char>> check(const std::vector<std::vector<int>> &map) {
	std::vector<Freq> row(9), clum(9), sq(9);
	for (auto i = 0; i < 9; ++i) {
		int sx{ (i / 3) * 3 }, sy{ (i % 3) * 3 };
		for (auto j = 0; j < 9; ++j) {
			row.at(i) += map.at(j).at(i);
			clum.at(i) += map.at(i).at(j);
			sq.at(i) += map.at(sy + square.at(j).second).at(sx + square.at(j).first);
		}
	}
	std::vector<std::vector<char>> res(9, std::vector<char>(9, ' '));
	for (auto x = 0; x < 9; ++x) {
		for (auto y = 0; y < 9; ++y) {
			if ((row.at(x) & map.at(y).at(x)) || (clum.at(y) & map.at(y).at(x)) || (sq.at((x / 3) * 3 + (y / 3)) & map.at(y).at(x))) {
				res.at(y).at(x) = '*';
			}
		}
	}
	return res;
}
int main() {
	int n;
	std::cin >> n;
	for (auto i = 0; i < n; ++i) {
		if (i != 0) {
			std::cout << std::endl;
		}
		std::vector<std::vector<int>> map(9, std::vector<int>(9));
		for (auto &clum : map) {
			for (auto &cell : clum) {
				std::cin >> cell;
			}
		}
		auto res = check(map);
		for (auto y = 0; y < 9; ++y) {
			for (auto x = 0; x < 9; ++x) {
				std::cout << res.at(y).at(x) << map.at(y).at(x);
			}
			std::cout << '\n';
		}
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int a[9][9],n;
  cin >> n;
  bool f,did=false; 
  while(n--){
    if(did)cout << endl;
    f=true;
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
        cin >> a[i][j];
      }
    }
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
        f=true;
        for(int k=0;k<9;k++){//横
          if(a[i][j]==a[i][k] and j!=k){
            cout << "*" << a[i][j];
            f=false;
            break;
          }
        }
        if(f){
          for(int k=0;k<9;k++){//縦
            if(a[i][j]==a[k][j] and i!=k){
              cout << "*" << a[i][j];
              f=false;
              break;
            }
          }
        }
        if(f){
          for(int ii=0;ii<9;ii++){//箱
            if(ii/3==i/3){
              for(int jj=0;jj<9;jj++){
                if(jj/3==j/3){
                  if(a[i][j]==a[ii][jj] and (i!=ii or j!=jj)){
                    cout << "*" << a[i][j];
                    f=false;
                  }
                }
                if(!f)break;
              }
            }
            if(!f)break;
          }
        }
        if(f){
          cout << " " << a[i][j];
        }
      }
      cout << endl;
    }
    did=true;
  }
  return 0;
}

C++: #include<cstdio>

using namespace std;

int pazzle[16][16];
bool check[16][16];

int main(void){
	int n;
	while(scanf("%d", &n) != EOF){
		while(n-- > 0){
			
			//ツ渉可甘コツ可サ
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					check[i][j] = false;
				}
			}
			
			//ツパツズツδ仰づ個禿偲ヲ
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					scanf("%d", &pazzle[i][j]);
				}
			}
			
			//ツ可。ツ板サツ津ィ
			for(int i = 0; i < 9; i++){
				for(int j= 0; j < 9; j++){
					for(int k = j+1; k < 9; k++){
						if(pazzle[i][j] == pazzle[i][k]){
							check[i][j] = true;
							check[i][k] = true;
						}
					}
				}
			}
			
			//ツ縦ツ板サツ津ィ
			for(int i = 0; i < 9; i++){
				for(int j= 0; j < 9; j++){
					for(int k = j+1; k < 9; k++){
						if(pazzle[j][i] == pazzle[k][i]){
							check[j][i] = true;
							check[k][i] = true;
						}
					}
				}
			}
			
			//3*3ツ板サツ津ィ
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					for(int k = j+1; k < 9; k++){
						int ax=3*(i/3)+j/3,ay=3*(i%3)+j%3;
						int bx=3*(i/3)+k/3,by=3*(i%3)+k%3;
//						printf("[%d][%d] | [%d][%d]\n",ax,ay,bx,by);
						if(pazzle[ax][ay] == pazzle[bx][by]){
							check[ax][ay] = true;
							check[bx][by] = true;
						}
					}
				}
			}
							
			
			for(int i = 0; i < 9; i++){
				for(int j = 0; j < 9; j++){
					printf("%c%d", check[i][j]?'*':' ',pazzle[i][j]);
				}puts("");
			}
			if(n>0)puts("");
		}
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {

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

	cin >> n;
	while(n) {
		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>
using namespace std;

int puzzle[9][9];
bool right(int y,int x){
  for(int i=0;i<9;i++){
    if(y!=i){
      if(puzzle[y][x]==puzzle[i][x]) return false;
    }
    if(x!=i){
      if(puzzle[y][x]==puzzle[y][i]) return false;
    }
  }

  int a=y,b=x;
  while(1){
    if(a%3==0) break;
    a--;
  }
  while(1){
    if(b%3==0) break;
    b--;
  }

  for(int i=a;i<a+3;i++){
    for(int j=b;j<b+3;j++){
      if(i!=y && j!=x){
	if(puzzle[i][j]==puzzle[y][x]){
	  return false;
	}
      }
    }
  }
  return true;
}


int main(){
  int n;
  cin>> n;
  while(n--){
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	cin>> puzzle[i][j];
      }
    }

    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	if(right(i,j)){
	  cout<< " "<< puzzle[i][j];
	}
	else {
	  cout<< '*'<< puzzle[i][j];
	}
      }
      cout<< endl;
    }
    cout<< endl;
  }
}