Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		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 <vector>
using namespace std;

int main(){
  typedef struct card{
    int num[4];//?????????????????????
    int sr;//??????????????????
  }card_sd;
  typedef struct inout{
    int num[4];
    int sr;
  }inout_sd;
  card_sd card;
  inout_sd inout;
  vector<int> bit;
  vector<int> hit;
  int h = 0;
  int abit = 0;
  int ahit = 0;

  for(h = 0;;h++){
    cin >> card.sr;

    if(card.sr == 0){
      break;
    }
    for(int g = 0;g<4;g++){
      card.num[3-g] = (card.sr)%10;
      card.sr /= 10;
    }
    cin >> inout.sr;

    for(int g = 0;g<4;g++){
      inout.num[3-g] = (inout.sr)%10;
      inout.sr /= 10;
    }
    for(int n = 0;n<4;n++){
      for(int t = 0;t<4;t++){
        if(card.num[n] == inout.num[t]){
          if(n == t){
            abit += 1;
          }else{
            ahit += 1;
          }
        }
      }
    }
    bit.push_back(abit);
    hit.push_back(ahit);
    abit = 0;
    ahit = 0;
  }
  for(int n = 0;n<h;n++){
    cout << bit[n] << " " << hit[n] << endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>

int main(void)
{
	char d1[5];
	char d2[5];
	
	while (1){
		int s, b;
		
		s = b = 0;
		scanf("%s%s", d1, d2);
		if (atoi(d1) == 0){
			break;
		}
		
		for (int i = 0; i < 4; i++){
			if (d1[i] == d2[i]){
				s++;
			}
			else {
				for (int j = 0; j < 4; j++){
					if (d1[i] == d2[j]){
						b++;
					}
				}
			}
		}
		
		printf("%d %d\n", s, b);
	}
	
	return (0);
}

C++: 
#include <iostream>
using namespace std;
int main(){
 char r[5];
 char a[5];
 int h,b;
 cin>>r>>a;
 while(1){
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[i]) h++;
    else if(r[i]==a[j]) b++;
    }
   }
  cout<<h/4<<' '<<b<<endl;
  h=0; b=0;
  cin>>r>>a;
  }

 
 return 0;

}

C++: #include<iostream>
#include<cstring>
#include<vector>
using namespace std;
int main()
{
  string r,a;
  for(;cin>>r>>a,r!="0";)
    {
      int hit=0,brow=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
		  brow++;
	      }
	  }
      cout<<hit<<" "<<brow<<endl;
	
    }
}

C++: #include<stdio.h>
int main(void)
{
	int p1[4],p2[4],n,m;
	int a,b;
	int i,j;
	int hit,blow;
	scanf("%d",&a);
	scanf("%d",&b);	
	while(a!=0 && b!=0){
		for(i=0;i<4;i++){
			p1[i]=a%10;
			a=a/10;
		}
		for(i=0;i<4;i++){
			p2[i]=b%10;
			b=b/10;
		}
		hit=0;
		blow=0;
		for(i=0;i<4;i++){
			if(p1[i]==p2[i]){
				hit++;
			}
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(p1[i]==p2[j]){
					blow++;
				}
			}
		}
		blow=blow-hit;
		printf("%d %d\n",hit,blow);

		scanf("%d",&a);
		scanf("%d",&b);
	}
	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; b = 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 <iostream>
#include <algorithm>
#include <map>

using namespace std;

class Solver{};

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

		map<int, int> mp;
		for (int i = 0; i < 4; i++) {
			int div = pow(10, i);
			mp.emplace((r / div) % 10, i);
		}

		int h = 0;
		int b = 0;
		for (int i = 0; i < 4; i++) {
			int div = pow(10, i);
			int val = (a / div) % 10;
			if (mp.find(val) != mp.end()) {
				if (mp[val] == i)h++;
				else b++;
			}
		}

		cout << h << " " << b << endl;
	}
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
for(int x=0;x>=0;x++){
int h;
int b;
char r[10],a[10];
char z[2]="0";
cin>>r>>a;
if((strcmp(r,z)==0)&&(strcmp(a,z)==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<<'\n';
}
return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <cstring>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

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

        int ans = 0;
        set<int> x, y;

        REP(i, 4)
        {
            if(r[i] == a[i])
            {
                ans++;
            }

            x.insert(r[i]);
            y.insert(a[i]);
        }

        int cnt = 0;

        for(auto i : x)
        {
            if(y.count(i))
            {
                cnt++;
            }
        }

        cout << ans << " " << cnt - ans << 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 <cstdio>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <sstream>

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

using namespace std;

int main(){
	string s1 , s2;

	while( cin >> s1 >> s2 )
	{
		int hit = 0 , blow = 0;
		if( s1 == "0" && s2 == "0" ) break;
		rep(i,4)
		{
			if( s1[i] == s2[i] ) hit++;
			else if( s1[0] == s2[i] || s1[1] == s2[i] || s1[2] == s2[i] || s1[3] == s2[i] ) blow++;
		}
		cout << hit << " " << blow << endl;
	}
	
	return 0;
}

C++: #include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;


int main(){

	int answer,player,table[10],S,hit,blow;

	while(true){
		scanf("%d %d",&answer,&player);
		if(answer == 0 && player == 0)break;

		for(int i = 0; i < 10; i++)table[i] = 0;
		hit = blow = 0;

		S = 1000;

		for(int i = 1; i <= 4; i++){
			table[answer/S] = i;
			answer %= S;
			S /= 10;
		}

		S = 1000;

		for(int i = 1; i <= 4; i++){
			if(table[player/S] == i){
				hit++;
			}else if(table[player/S] != 0){
				blow++;
			}
			player %= S;
			S /= 10;
		}

		printf("%d %d\n",hit,blow);

	}

    return 0;
}

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

int main()
{
bool A=1;
while(A){
 char stra[10], strb[10];
 int hit=0,bro=0;
 cin>>stra>>strb;

 for(int i=0;i<4;i++){
  if(stra[i]==strb[i]){
	hit++;}
  for(int j=0;j<4;j++){
	if(stra[i]==strb[j])
	 bro++;}
 }
if(stra[0]=='0'&&stra[1]=='\0'){break;}
bro=bro-hit;
cout<<hit<<' '<<bro<<'\n';

}
return 0;
}