Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	table := [9][9]int{}
	check := [9][9]bool{}
	n, _ := strconv.Atoi(scanner.Text())
	for n > 0 {
		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()
		}
		n--
	}
}

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

C++: #include<iostream>
#include<string>
using namespace std;
int main()
{
  int n;

  cin >> n;

  int pazzle[n][9][9];
  
  int point[n][9][9];
  
  //point={0}
  for(int i = 0;i < n;++i){
    for(int j = 0;j < 9;++j){
      for(int k = 0;k < 9;++k){
	point[i][j][k] = 0;
      }
    }
  }
			     
  
  //scan
  for(int i = 0;i < n;++i){
    for(int j = 0;j < 9;j++){
      for(int k = 0;k < 9;k++){
	cin >> pazzle[i][j][k];
      }
    }
  }

  //syori
  for(int i = 0;i < n;i++){
    for(int j = 0;j < 9;j++){
      for(int k = 0;k < 9;k++){
	for(int l = 0;l < 9;l++){
	  //tate
	  if(pazzle[i][j][k] == pazzle[i][j][l] && k != l){
	    point[i][j][k] = 1;
	    point[i][j][l] = 1;
	  }
	  //yoko
	  if(pazzle[i][l][j] == pazzle[i][k][j] && k != l){
	    point[i][l][j] = 1;
	    point[i][k][j] = 1;
	  }
	}
      }
      //masu
      switch(j){
	
      case 0:{
	for(int a = 0;a < 3;a++){
	  for(int b = 0;b < 3;b++){
	    for(int c = 0;c < 3;c++){
	      for(int d = 0;d < 3;d++){
		if(pazzle[i][a][b] == pazzle[i][c][d] && (a != c && b != d) ){
		  point[i][a][b] = 1;
		  point[i][c][d] = 1;
		  break;
		}
	      }
	    }
	  }
	}
      }

      case 1:{
	for(int a = 0;a < 3;a++){
	  for(int b = 3;b < 6;b++){
	    for(int c = 0;c < 3;c++){
	      for(int d = 3;d < 6;d++){
		if(pazzle[i][a][b] == pazzle[i][c][d] && (a != c && b != d) ){
		  point[i][a][b] = 1;
		  point[i][c][d] = 1;
		  break;
		}
	      }
	    }
	  }
	}
      }

      case 2:{
	for(int a = 0;a < 3;a++){
	  for(int b = 6;b < 9;b++){
	    for(int c = 0;c < 3;c++){
	      for(int d = 6;d < 9;d++){
		if(pazzle[i][a][b] == pazzle[i][c][d] && (a != c && b != d) ){
		  point[i][a][b] = 1;
		  point[i][c][d] = 1;
		  break;
		}
	      }
	    }
	  }
	}
      }

      case 3:{
	for(int a = 3;a < 6;a++){
	  for(int b = 0;b < 3;b++){
	    for(int c = 3;c < 6;c++){
	      for(int d = 0;d < 3;d++){
		if(pazzle[i][a][b] == pazzle[i][c][d] && (a != c && b != d) ){
		  point[i][a][b] = 1;
		  point[i][c][d] = 1;
		  break;
		}
	      }
	    }
	  }
	}
      }

      case 4:{
	for(int a = 3;a < 6;a++){
	  for(int b = 3;b < 6;b++){
	    for(int c = 3;c < 6;c++){
	      for(int d = 3;d < 6;d++){
		if(pazzle[i][a][b] == pazzle[i][c][d] && (a != c && b != d) ){
		  point[i][a][b] = 1;
		  point[i][c][d] = 1;
		  break;
		}
	      }
	    }
	  }
	}
      }

      case 5:{
	for(int a = 3;a < 6;a++){
	  for(int b = 6;b < 9;b++){
	    for(int c = 3;c < 6;c++){
	      for(int d = 6;d < 9;d++){
		if(pazzle[i][a][b] == pazzle[i][c][d] && (a != c && b != d)){
		  point[i][a][b] = 1;
		  point[i][c][d] = 1;
		  break;
		}
	      }
	    }
	  }
	}
      }

      case 6:{
	for(int a = 6;a < 9;a++){
	  for(int b = 0;b < 3;b++){
	    for(int c = 6;c < 9;c++){
	      for(int d = 0;d < 3;d++){
		if(pazzle[i][a][b] == pazzle[i][c][d] && (a != c && b != d) ){
		  point[i][a][b] = 1;
		  point[i][c][d] = 1;
		  break;
		}
	      }
	    }
	  }
	}
      }

      case 7:{
	for(int a = 6;a < 9;a++){
	  for(int b = 3;b < 6;b++){
	    for(int c = 6;c < 9;c++){
	      for(int d = 3;d < 6;d++){
		if(pazzle[i][a][b] == pazzle[i][c][d] && (a != c && b != d) ){
		  point[i][a][b] = 1;
		  point[i][c][d] = 1;
		  break;
		}
	      }
	    }
	  }
	}
      }

      case 8:{
	for(int a = 6;a < 9;a++){
	  for(int b = 6;b < 9;b++){
	    for(int c = 6;c < 9;c++){
	      for(int d = 6;d < 9;d++){
		if(pazzle[i][a][b] == pazzle[i][c][d] && (a != c && b != d) ){
		  point[i][a][b] = 1;
		  point[i][c][d] = 1;
		  break;
		}
	      }
	    }
	  }
	}
      }
      }
    }
  }      

  //print
  for(int i = 0;i < n;i++){
    for(int j = 0;j < 9;j++){
      for(int k = 0;k < 9;k++){
	if(!point[i][j][k]){
	  cout << " " << pazzle[i][j][k];
	}
	else{
	  cout << "*" << pazzle[i][j][k];
	}
      }
      cout << endl;
    }
    if(i < n-1)cout << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
int mp[9][9],flg[9][9],visited[9][9];


void mark(int x,int y, int num){
  for(int i=y;i<y+3;i++)
    for(int j=x;j<x+3;j++)
      if(mp[i][j]==num) flg[i][j]=1;
}

void  check(int y,int x){
  int used[10]={};
  for(int i=y;i<y+3;i++)
    for(int j=x;j<x+3;j++){
      if(used[mp[i][j]]) mark(i,j,mp[i][j]);
      used[mp[i][j]]=visited[i][j]=1;
    }
}

int main(){
  int q;
  cin>>q;
  while(q--){
    for(int i=0;i<9;i++)
      for(int j=0;j<9;j++)cin>>mp[i][j];
    memset(flg,0,sizeof(flg));

    for(int i=0;i<9;i++){
      int used[10]={};
      for(int j=0;j<9;j++){
	for(int k=0;k<9&&used[mp[i][j]];k++) 
	  if(mp[i][k]==mp[i][j])flg[i][k]=1;	 
	used[mp[i][j]]=1;
      }
    }
    for(int i=0;i<9;i++){
      int used[10]={};
      for(int j=0;j<9;j++) {
	if(used[mp[j][i]])
	  for(int k=0;k<9;k++) if(mp[j][i]==mp[k][i])flg[k][i]=1;
	used[mp[j][i]]=1;
      }
    }

    memset(visited,0,sizeof(visited));
    for(int i=0;i<9;i++)
      for(int j=0;j<9;j++)
	if(visited[i][j]==0) check(i,j);

    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++)cout <<(flg[i][j]?"*":" ")<<mp[i][j];
      cout <<endl;
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int n;
int board[9][9];
int dxy[3][3] = { { 0, 1, 2},
		  {-1, 0, 1},
		  {-2,-1, 0} };

bool cheak(int y,int x){
  for(int i=0;i<9;i++){
    if(i != y && board[y][x] == board[i][x]) return true;
    if(i != x && board[y][x] == board[y][i]) return true;
  }
  int py = y % 3;
  int px = x % 3;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      int nx = x+dxy[px][i];
      int ny = y+dxy[py][j];
      if(nx == x && ny == y) continue;
      if(board[y][x] == board[ny][nx]) return true;
    }
  }
  return false;
}

int main(){
  cin >> n;
  while(n--){
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	cin >> board[i][j];
      }
    }
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	if(cheak(i,j)) cout << "*" << board[i][j];
	else cout << " " << board[i][j];
      }
      cout << endl;
    }
  }
}