Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		_a, _ := strconv.Atoi(buf[0])
		_b, _ := strconv.Atoi(buf[1])
		a := strings.Split(buf[0], "")
		b := strings.Split(buf[1], "")
		if _a == 0 && _b == 0 {
			break
		}
		hit := 0
		blow := 0
		for i, av := range a {
			for j, bv := range b {
				if i == j && av == bv {
					hit++
				}
				if i != j && av == bv {
					blow++
				}
			}
		}
		fmt.Println(hit, blow)
	}
}

C++: #include<cstdio>

#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

int main(){
	for(char r[5],a[5];scanf("%s%s",r,a),r[1];){
		int hit=0,blow=0;
		rep(i,4)rep(j,4)if(r[i]==a[j]){
			if(i==j)	hit++;
			else		blow++;
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

C++: #include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (long u = 0; u < 12000; u++)
	{
		string a = "",b = "";

		cin >> a >> b;
		if (a == "0" && b == "0")
		{
			break;
		}

		int hit = 0,bro = 0;

		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				if (a.substr(i,1) == b.substr(j,1) && i == j)
				{
					hit += 1;
				}
				else if (a.substr(i,1) == b.substr(j,1))
				{
					bro += 1;
				}
			}
		}

		cout << hit << " " << bro << endl;
	}
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[10],b[10];
	while(true){
	cin>>a>>b;
	if(strcmp(a,"0")==0)break;
	int x=0,y=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(i<j)continue;
			if(a[i]==b[j]){
			if(i==j)x++;
			else y++;
			}			

		}
	}
	cout<<x<<" "<<y<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
  string sol,ans;
  int i,j;


  while( cin >> sol >> ans ){
    if(sol=="0" &&  ans=="0" ) break;
    int hit=0,blow=0;
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(sol[i]==ans[j] && i == j){
	  hit++;
	  break;
	}else if(sol[i]==ans[j]){
	  blow++;
	  break;
	}
      }
    }
    cout << hit << " " << blow << endl;
    hit=0;
    blow=0;
  }
  
  return 0;
}

C++: #include<iostream>
int main(){int f[2],i,j;std::string r,a;while(std::cin>>r>>a,r!="0"&&a!="0"){for(f[0]=f[1]=i=0;i<4;i++)for(j=4;j-->0;)if(a[i]==r[j])f[i!=j]++;printf("%d %d\n",f[0],f[1]);}}

C++: #include <iostream>
#include <string>

using namespace std;


int main(){

  while(1){
    string n,m;
    cin >> n >> m;
    if(n == "0" && m == "0") break;
    int hit=0,br=0;
    for(int i=0;i<4;i++){
      if(n[i] == m[i]) hit++;
    }
    int hoge[10]={};
    for(int i=0;i<4;i++){
      hoge[stoi(n.substr(i,1))]=1;
    }
    for(int i=0;i<4;i++){
      if(hoge[stoi(m.substr(i,1))] == 1) br++;
    }
    br -= hit;
    cout << hit << " " << br <<endl;



  }

}

C++: #include<iostream>
using namespace std;

int main(){
 
 char qwe[6],ans[6];

 int hit,blow,count;

     count = 0;
 
 while(hit != 4){
    cin >> qwe >> ans;
    hit = 0 ;
    blow = 0;


   for(int i=0; i<4; i++){
      
       for(int g=0; g<4; g++){

           if(qwe[i] == ans[g]){
               
                if(i == g)
                      hit++;
                else
                      blow++;
            }
       }
    }
   
   cout << hit << " " << blow << endl;
   count++;
 }

  while(hit != 4 || count != 0){
    cin >> qwe >> ans;
    hit = 0 ;
    blow = 0;

   for(int i=0; i<4; i++){
      
       for(int g=0; g<4; g++){

           if(qwe[i] == ans[g]){
               
                if(i == g)
                      hit++;
                else
                      blow++;
            }
       }
    }
   
   cout << hit << " " << blow << endl;
   
   count--;
 }

 return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	char ans[5],a[5];
	int hit,blow;
	while(true){
		cin >> ans >> a;
		if(ans[0] == '0' && a[0] == '0')
			return 0;
		hit = 0;
		blow = 0;
		for(int i=0; i<4; i++){
			for(int j=0; j<4; j++){
				if(ans[i] == a[j]){
					if(i == j)
						hit++;
					else
						blow++;
					break;
				}
			}
		}
		cout << hit << ' ' << blow << endl;
	}
}

C++: #include <cstdio>
#include <cmath>
using namespace std;

int n[2];
bool num[2][10];

int main(){
	while(scanf("%d%d",&n[0],&n[1])){
		if(n[0] == 0 && n[1] == 0) break;
		for(int i = 0; i < 2; i++) for(int j = 0; j < 10; j++) num[i][j] = false;
		int h = 0, d = 0;
		for(int i = 0; i < 2; i++) for(int j = 0; j < 4; j++) num[i][(n[i]%(int)pow(10,4-j))/(int)pow(10,3-j)] = true;
		for(int i = 0; i < 4; i++) if((n[0]%(int)pow(10,4-i))/(int)pow(10,3-i) == (n[1]%(int)pow(10,4-i))/(int)pow(10,3-i)) h++;
		for(int i = 0; i < 10; i++) if(num[0][i] == true && num[1][i] == true) d++;
		printf("%d %d\n", h, d-h);
	}
}

C++: #include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

main(){
  int m,n;
  int  x[4],y[4];
  while(1){
    int h=0,b=0;
    cin >> m >> n;
    if(n==0 && m==0) break;

    for(int i=0;i<4;i++){
      x[3-i]=m%10;
      y[3-i]=n%10;
      m=m/10;
      n=n/10;
    }

    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	if(x[i]==y[j]){
	  if(i==j) h++;
	  else b++;
	}
      }
    }
    cout << h << " " << b << endl;
  }
}

C++: #include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		string r,a;
		cin >> r >> a;
		if(r=="0" && a=="0")
			break;

		int hit=0,blow=0;

		for(int i=0 ;i<4 ;i++){
			for(int j=0 ;j<4 ;j++){
				if(r[i] == a[j]){
					if(i==j)
						hit++;
					else
						blow++;
				}
			}
		}
		cout << hit << ' ' << blow << endl;
	}
	return 0;
}

C++: #include<iostream>
int main(){int h,b,i,j;std::string r,a;while(std::cin>>r>>a,r!="0"&&a!="0"){for(h=b=i=0;i<4;i++)for(j=4;j-->0;)if(a[i]==r[j])i=j?h++:b++;printf("%d %d\n",h,b);}}

C++: #include <iostream>
#include <cstring>
using namespace std;

int main(){
	int length = 4;
	char taroNomber[length+1];
	char hanakoNomber[length+1];
	int hitCount = 0;
	int blowCount = 0;
	while(true){
		cin >> taroNomber;
		cin >> hanakoNomber;
		hitCount = 0;
		blowCount = 0;
		if(strlen(taroNomber)==1){
			break;
		}
		for(int i=0;i<length;i++){
			for(int j=0;j<length;j++){
				if(taroNomber[i]==hanakoNomber[j]){
					if(i==j){
						hitCount++;
						break;
					}else{
						blowCount++;
						break;
					}
				}
			}
		}
		cout << hitCount << ' ' << blowCount << '\n';
	}
	return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
	char num1[5], num2[5];
	int hit, blow;
	while(1){
		cin >> num1 >> num2;
		if(num1[0] == '0' && num2[0] == '0') break;
		
		hit = blow = 0;
		for(int n1 = 0;n1 < 4;n1++){
			for(int n2 = 0;n2 < 4;n2++){
				if(n1 == n2 && num1[n1] == num2[n2]) hit++;
				else if(num1[n1] == num2[n2]) blow++;
			}
		}
		cout << hit << ' ' << blow << endl;
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
  int answer[4]={0},responce[4]={0};

  while(1){
    int hit=0,blow=0;
    int A,R;

    cin>>A>>R;

    if(A==0 && R==0)
      break;

    answer[0]=A/1000;
    answer[1]=(A/100)%10;
    answer[2]=(A/10)%10;
    answer[3]=A%10;

    responce[0]=R/1000;
    responce[1]=(R/100)%10;
    responce[2]=(R/10)%10;
    responce[3]=R%10;
    
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
        if(answer[i]==responce[j]){
          if(i==j)
            hit++;
          if(i!=j)
            blow++;
        }
      }
    }

    cout<<hit<<" "<<blow<<endl;
  }
  
}