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>
using namespace std;

int main()
{
    string s, t;
    int j[10];

    while( cin >> s >> t )
    {
        if( s == "0" && t == "0" )
            break;
        for( int i = 0; i < 10; i++ )
            j[i] = 0;

        int hit = 0, blow = 0;
        for( int i = 0; i < 4; i++ )
        {
            if( s[i] == t[i] )
                hit++;
            j[s[i]-'0']++;
            j[t[i]-'0']++;
        }
        for( int i = 0; i < 10; i++ )
            if( j[i] == 2 )
                blow++;
        cout << hit << " " << blow - hit << endl;
    }
    return 0;
}

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

int main(){
int h=0,b=0;
char r[5];
char a[5];
 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<vector>

using namespace std;

int main()
{
  while(1){
    int hit = 0;
    int blow = 0;
    int q,a;
    cin>>q;
    cin>>a;

    if(q == 0 && a == 0){
      break;
    }

    int q2 = q;
    int a2 = a;

    vector<int> q3;
    vector<int> a3;

    //hit
    if(q2/1000 == a2/1000){
      ++hit;
    }
    q3.push_back(q2/1000);
    a3.push_back(a2/1000);
    q2 = q2 % 1000;
    a2 = a2 % 1000;

    if(q2/100 == a2/100){
      ++hit;
    }
    q3.push_back(q2/100);
    a3.push_back(a2/100);
    q2 = q2 % 100;
    a2 = a2 % 100;

    if(q2/10 == a2/10){
      ++hit;
    }
    q3.push_back(q2/10);
    a3.push_back(a2/10);
    q2 = q2 % 10;
    a2 = a2 % 10;

    if(q2 == a2){
      ++hit;
    }
    q3.push_back(q2);
    a3.push_back(a2);

    //blow
    for(int e : q3){
      for(int a : a3){
        if(e == a){
          ++blow;
          break;
        }
      }
      if(e == a){
        break; 
      }
    }

    blow = blow - hit;
    cout<<hit<<" "<<blow<<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];
			U += "0";
			a[i] = stoi(U) / 10;
		}
		for (int i = 0; i < 4; i++) {
			U = T[i];
			U += "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 <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  while(cin >> a >> b){
    if(a == "0" && b == "0") break;
    ll hit = 0,blow = 0;
    map<char,int> m;
    rep(i,4){
      if(a[i] == b[i]) ++hit;
      m[a[i]]++;
      m[b[i]]++;
    }
    rep(i,10){
      if(m['0'+i] > 1) ++blow;
    }
    cout << hit << " " << blow - hit<<endl;
  }
  return 0;
}

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

int main(){

    string n1,n2;
    int hit,blow;

    while(cin>>n1>>n2&&n1!="0"){

        hit=blow=0;
        for(int i=0;i<4;i++){
            if(n1[i]==n2[i]) hit++;
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(i!=j&&n1[i]==n2[j]) blow++;
            }
        }

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

    return 0;
}

C++: // 2011/06/30 Tazoe

#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;
		int blw = 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
						blw++;

		cout << hit << ' ' << blw << endl;
	}

	return 0;
}

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

using namespace std;

int main(void){

	string A,B;
	char ch;
	int use[10];
	int h,b;

	while(1){

		cin>>A>>B;
		if(A=="0"&&B=="0") break;

		h=0;b=0;
		for(int i=0;i<10;i++) use[i]=0;

		for(int i=0;i<4;i++){
			if(A[i]==B[i]) h++;
			use[A[i]-'0']++;
		}
		for(int i=0;i<4;i++){
			b+=use[B[i]-'0'];
		}
		b-=h;

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

}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        string a, b;
        cin >> a >> b;
        if(a == "0")
            return 0;

        vector<bool> num(10, false);
        for(int i=0; i<4; ++i)
            num[a[i]-'0'] = true;

        int ret1 = 0;
        int ret2 = 0;
        for(int i=0; i<4; ++i){
            if(a[i] == b[i])
                ++ ret1;
            else if(num[b[i]-'0'])
                ++ ret2;
        }

        cout << ret1 << ' ' << ret2 << endl;
    }
}

C++: #include<string.h>
#include<stdio.h>
int main()
{
	int h,b,i,j;
	char r[5],a[5];
	while(1){
		scanf("%s %s",r,a);
		if(strcmp(r,"0")==0&&strcmp(a,"0")==0){
			break;
		}
		h=0;
		b=0;
		for(i=0;i<4;i++){
			if(r[i]==a[i]){
				h++;
				r[i]='r';
				a[i]='a';
			}
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(r[i]==a[j]){
					b++;
					r[i]='r';
					a[j]='a';
				}
			}
		}
		printf("%d %d\n",h,b);
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a,s,d[5],f[5],g,h,z,i,j;
	scanf("%d %d",&a,&s);
	while(a!=0&&s!=0){
		z=0;
		h=0;
		g=10;
		for(i=1;i<=4;i++){
			d[i]=a%g;
			f[i]=s%g;
			a=a/10;
			s=s/10;
		}
		for(i=1;i<=4;i++){
			if(d[i]==f[i]){
					h++;
			}
			for(j=1;j<=4;j++){
				if(i!=j&&d[i]==f[j]){
					z++;
				}
			}
		}
		printf("%d %d\n",h,z);
		scanf("%d %d",&a,&s);
	}
	return 0;
}