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<iostream>
#include<string.h>
using namespace std;
int main()
{
	int h=0,b=0;
	char s[4], s2[4];
	while (true){
		cin >> s >> s2;
		if (strlen(s)==1){
			return 0;
		}
		h = 0, b = 0;
		for (int i = 0; i < 4; i++){
			if (s[i] == s2[i]){
				h++;
				s[i] = '-';
				s2[i] = '-';
			}
		}
		for (int i = 0; i < 4; i++){
			for (int i2 = 0; i2 < 4; i2++){
				if (i != i2&&s[i] != '-'&&s2[i2] != '-'&&s[i]==s2[i2]){
					b++;
				}
			}
		}
		cout << h << " " << b << endl;
	}
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <P,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

int main(){
	char a[32],b[32];
	while(~scanf("%s %s",a,b)){
		if(a[0]==b[0] && b[0] == '0') break;
		int hit=0;
		int brow=0;

		for(int i=0;i<4;i++){
			if(a[i]==b[i]){
				hit++;
				continue;
			}
			for(int j=0;j<4;j++){
				if(i==j) continue;
				if(b[i] == a[j]){
					brow++;
					break;
				}
			}

		}

		printf("%d %d\n",hit,brow);
	}
}

C++: #include <stdio.h>
#include <string.h>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
char a[4], b[4]; int  hit, blow;
int main() {
	while (true) {
		scanf("%s%s", a, b);
		if (strlen(a) == 1 && strlen(b) == 1) break;
		hit = 0; blow = 0;
		for (int i = 0; i < 4; i++) {
			if (a[i] == b[i]) hit++;
			for (int j = 0; j < 4; j++) {
				if (a[i] == b[j]) {
					blow++; hit--; break;
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  string r, a;
  while(cin>>r>>a, r!="0"){
    int h=0, b=0;
    for(int i=0;i<4;++i){
      if(r[i] == a[i]){
        h++;
        r[i] = 'X'; a[i] = 'Y';
      }
    }
    for(int i=0;i<4;++i){
      for(int j=0;j<4;++j){
        if(r[i] == a[j]){
          b++;
          break;
        }
      }
    }
    cout<<h<<" "<<b<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
string S, T, U; int a[4], b[4], h, v;
int main() {
	while (cin >> S >> T) {
		h = 0; v = 0;
		if (S == "0") { break; }
		for (int i = 0; i < 4; i++) {
			U = S[i] + '0';
			a[i] = stoi(U) / 10;
		}
		for (int i = 0; i < 4; i++) {
			U = T[i] + '0';
			b[i] = stoi(U) / 10;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (a[i] == b[j]) {
					if (i == j) { h++; }
					else { v++; }
				}
			}
		}
		cout << h << ' ' << v << endl;
	}
}

C++: #include<stdio.h>
int a,b;
int aa[4],bb[4];
int main(void){
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0 && b==0){
			break;
		}
		int kake=1000,cnt=0;
		while(cnt!=4){
			aa[cnt]=a/kake;
			bb[cnt]=b/kake;
			a-=aa[cnt]*kake;
			b-=bb[cnt]*kake;
			cnt++;
			kake/=10;
		}
		int i,j;
		/*for(i=0;i<4;i++){
			printf("%d %d\n",aa[i],bb[i]);
		}
		printf("\n");*/
		int h=0,b=0;
		for(i=0;i<4;i++){
			if(aa[i]==bb[i]){
				h++;
				aa[i]=9999;
				bb[i]=9999;
			}
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(aa[i]==bb[j] && aa[i]!=9999 && bb[j]!=9999){
					b++;
					//printf("%d %d\n",aa[i],bb[j]);
					aa[i]=9999;
					bb[j]=9999;
				}
			}
		}
		printf("%d %d\n",h,b);
	}
	return 0;
}

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

int main(){
  string r,a;
  while(1){
    cin >> r >> a;
    if(r == "0" && a == "0") break;
    int h=0,b=0;
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	if(r[i] == a[j]){
	  if(i==j) h++;
	  else b++;
	  break;
	}
      }
    }
    cout << h << " " << b << endl;
  }
}

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

int main(){
int h=0,b=0;
char r[4];
char a[4];
cin >> r >> a;
for(int i=0;i<4;i++){
	if(r[i]==a[i]){
          h++;
	}
}
for(int i=0;i<4;i++){
 for(int j=0;j<4;j++){
	  if(r[i]==a[j]){
	    b++;
	 }
  }
}
b=b-h;
cout << h << ' ' << b << endl;
return 0;
}

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

int main()
{
    while(1)
    {
        string r;
        string a;
        int hit = 0;
        int blow = 0;
        cin >> r >> a;
        if(r == "0" && a == "0")
        {
            break;
        }
        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>

using namespace std;

int main(){

  int in[5], out[5];

  while(1){

    cin >> in[0] >> out[0];

    if(in[0] == 0 && out[0] == 0) break;

    for(int i = 1; i < 5; i++){
      in[i] = in[0] % 10;
      in[0] /= 10;
      out[i] = out[0] % 10;
      out[0] /= 10;
    }

    int hit = 0, blow = 0;

    for(int i = 1; i < 5; i++){
      if(in[i] == out[i]) hit++;
    }

    for(int i = 1; i < 5; i++){
      for(int j = 1; j < 5; j++){
	if(in[i] == out[j]) blow++;
      }
    }

    blow -= hit;

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

  }

  return 0;
}

C++: #include <cstdio>

int main(void){
char inp[2][5];
int i,j,p,q;
while(1){
scanf("%s%s",inp[0],inp[1]);
if(inp[0][1]==0)break;
p=0;q=0;

for(i=0;i<4;i++){
if(inp[0][i]==inp[1][i])p++;
for(j=0;j<4;j++){
if(inp[0][i]==inp[1][j])q++;
}
}
printf("%d %d\n",p,q-p);
}
return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
int h;
int b;
int n=1;
while(n<0){
char r[10],a[10];
cin>>r>>a;
if((r[0]=='0')&&(a[0]=='0')){
break;
}
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
if(r[i]==a[j]){
b++;
if(i==j){
h++;
}
}
}
}
}
b=b-h;
cout<<h<<' '<<b<<endl;
return 0;
}

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

int main(){
 while(1){
	string stra,strb;
	cin>>stra>>strb;
	int h,b;

	if((stra=="0")&&(strb=="0")){
	 break;}

	for(int i=0;i<4;i++){
	 if(stra[i]==strb[i]){
		h++;
	 }
	 for(int j=0;j<4;j++){
		if(stra[i]==strb[j]){
			b++;
		}
	 }
	}

  b=b-h;
  cout<<h<<' '<<b<<'\n';
 }
return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int R, A; //正解と回答

    while(true){
        cin >> R >> A;
        if(R == 0 && A == 0) break;

        int r[4], a[4]; //４桁の数字を分解するための箱
        for(int i = 0; i < 4; i++){
            r[3 - i] = R % 10;
            a[3 - i] = A % 10;
            R /= 10;
            A /= 10;
        }

        int c_hit = 0; //ヒットの数を数える
        int c_blow = 0; //ブローの数を数える

        for(int i = 0; i < 4; i++){
            if(r[i] == a[i])
                c_hit++;
            for(int j = 0; j < 4; j++){
                if(i != j) 
                    if(r[i] == a[j]) c_blow++;
            }
        }
        cout << c_hit << " " << c_blow << endl;
    }
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
int h;
int b;
int n=1;
while(n<0){
char r[10],a[10];
cin>>r>>a;
if((r[0]=='0')&&(a[0]=='0')){
break;
}
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
if(r[i]==a[j]){
b++;
if(i==j){
h++;
}
}
}
}
}
b=b-h;
cout<<h<<' '<<b<<endl;
return 0;
}