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 <cstdio>

int main(void)
{
    char r[5], a[5];
    while (1){
        scanf("%s %s", r, a);
        if (r[0] == '0' && a[0] == '0') break;
        int hit = 0, blow = 0;
        for (int i = 0; i < 4; i++){
            if (r[i] == a[i]) hit++;
        }
        for (int i = 0; i < 4; i++){
            for (int j = 0; j < 4; j++){
                if (r[i] == a[j]) blow++;
            }
        }
        printf("%d %d\n", hit, blow - hit);
    }
    
    return (0);
}

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

using namespace std;
int a, b, cnt[10];
int main(){
    while(cin >> a >> b, a | b){
	fill(cnt, cnt + 10, 0);
	int hit = 0, blow = 0;
	for(int i = 0;i < 4;i++){
	    cnt[a%10]++;
	    cnt[b%10]++;
	    if(cnt[a%10] == 2)blow++;
	    if(cnt[b%10] == 2)blow++;
	    if(a%10 == b%10)hit++,blow--;
	    a/=10,b/=10;
	}
	cout << hit << " " << blow - hit << endl;
    }
    return 0;
}

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

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

 if(stra[0]=='0'&&stra[1]=='\0'){break;}

 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++;
		}
	}
 }
bro=bro-hit;
cout<<hit<<' '<<bro<<'\n';

}

return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

int main()
{
  char p1[4], p2[4];
  while (cin >> p1 >> p2, p1[0] + p2[0] != '0' + '0'){
    int h = 0, b = 0;
    REP(i, 4){
      REP(j, 4){
        if (p1[i] == p2[j] && i == j) h++;
        else if (p1[i] == p2[j]) b++;
      }
    }
    cout << h << " " << b << endl;
  }
}

C++: 
#include <iostream>
#include <algorithm>
#include<vector>
#include <queue>
using namespace std;
int main()
{
	int a, b;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0)break;
		int aa[5] = { a / 1000,(a / 100) % 10,(a / 10) % 10,a % 10,0 };
		int bb[5] = { b / 1000,(b / 100) % 10,(b / 10) % 10,b % 10,0 };
		int c = 0;
		int d = 0;
		if (aa[0] == bb[0]) {
			bb[0] = -1;
			c++;
		}
		if (aa[1] == bb[1]) {
			bb[1] = -1;
			c++;
		}
		if (aa[2] == bb[2]) {
			bb[2] = -1;
			c++;
		}
		if (aa[3] == bb[3]) {
			bb[3] = -1;
			c++;
		}
		if (aa[0] == bb[1]) {
			bb[1] = -1;
			d++;
		}
		if (aa[0] == bb[2]) {
			bb[2] = -1;
			d++;
		}
		if (aa[0] == bb[3]) {
			bb[3] = -1;
			d++;
		}
		if (aa[1] == bb[0]) {
			bb[0] = -1;
			d++;
		}
		if (aa[1] == bb[2]) {
			bb[2] = -1;
			d++;
		}
		if (aa[1] == bb[3]) {
			bb[3] = -1;
			d++;
		}
		if (aa[2] == bb[0]) {
			bb[0] = -1;
			d++;
		}
		if (aa[2] == bb[1]) {
			bb[3] = -1;
			d++;
		}
		if (aa[2] == bb[3]) {
			bb[3] = -1;
			d++;
		}
		if (aa[3] == bb[0]) {
			bb[0] = -1;
			d++;
		}
		if (aa[3] == bb[1]) {
			bb[1] = -1;
			d++;
		}
		if (aa[3] == bb[2]) {
			bb[2] = -1;
			d++;
		}
		cout << c << " " << d << endl;
		c = 0; d = 0;
	}
	
}

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

using namespace std;

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

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  string a, b;
  while(cin >> a >> b) {
    if(a == "0") break;
    map<char, int> mp;
    int hit = 0;
    int br = 0;
    rep(i, 0, 4) {
      if(a[i] == b[i]) hit++;
      else {
        if(mp[a[i]]) {
          mp[a[i]] = 0;
          br++;
        }else mp[a[i]] = 1;
        if(mp[b[i]]) {
          mp[b[i]] = 0;
          br++;
        }else mp[b[i]] = 1;
      }
    }

    cout << hit << " " << br << endl;
  }
}

C++: #include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  string a,b;
  int hit, blow;
  bool flag[4];
  while(cin >> a >> b){
    if(a[0] == '0' && b[0] == '0') return 0;
    for(int i=0; i<4; i++){
    }

    hit = 0; 
    blow = 0;
    for(int i=0; i<4; i++)
      flag[i] = false;

    for(int i=0; i<4; i++){
	if(a[i] == b[i]){
	  hit++;
	  flag[i] = true;
	}
	for(int j=0; j<4; j++){
	  if( a[i] == b[j] &&  flag[i] != true){
	    blow++;
	  }
	}
    }
    cout << hit << " " << blow << endl;
  }
}

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

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

 int hit,blow,count;

 
 
 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<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<iostream>
#include<cstring>
using namespace std;

int main(){
  int hit=0,blow=0;
  char r[10],a[5];
  cin>>r>>a;
  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<<"\n";
  return 0;
}

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

int main(){
    while(true){
        string a, b;
        cin >> a;
        cin >> b;
        if(a == "0")
            break;
        
        int hit = 0;
        int blow = 0;
        for(int i=0;i<4;++i){
            if(a[i] == b[i]) hit++;
        }
        for(int i=0;i<4;++i){
            for(int j=0;j<4;++j){
                if(i == j) continue;
                if(a[i] == b[j]) blow++;
            }
        }
        cout << hit << " " << blow << endl;
    }
}

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

int main(void){
  int Q,A,Qn[4],An[4],h,b;

  while(1){

    h = b = 0;
    cin >> Q >> A;
    if( Q == 0 && A == 0 ) break;

    Qn[0] = (Q/1000)%10;
    Qn[1] = (Q/100)%10; 
    Qn[2] = (Q/10)%10; 
    Qn[3] = Q%10;

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

    if( Q == A ) h = 4;
    else{
      for( int i = 0 ; i < 4 ; i++ ){
	for( int j = 0 ; j < 4 ; j++ ){
	  if( Qn[i] == An[j] && i == j ) h++;
	  else if( Qn[i] == An[j] && i != j ) b++;
	}
      }
    } 
 

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

  }

  return 0;
}