Go: package main

import "fmt"

func main() {
	var a1, a2, a3, a4, b1, b2, b3, b4 int
	for {
		i, _ := fmt.Scan(&a1, &a2, &a3, &a4)
		if i == 0 {
			break
		}
		fmt.Scan(&b1, &b2, &b3, &b4)
		a := [4]int{a1, a2, a3, a4}
		b := [4]int{b1, b2, b3, b4}
		var hit, blow int

		for j := 0; j < 4; j++ {
			for k := 0; k < 4; k++ {
				if a[j] == b[k] {
					if j == k {
						hit++
					} else {
						blow++
					}
				}
			}
		}
		fmt.Println(hit, blow)
	}
}

C++: #include <iostream>

int main()
{
	int v[2][4];
	while( std::cin>>v[0][0]>>v[0][1]>>v[0][2]>>v[0][3]>>v[1][0]>>v[1][1]>>v[1][2]>>v[1][3] )
	{
		int hit = 0, blow = 0;

		for( int i=0; i<4; ++i )
		{
			if( v[0][i] == v[1][i] )
			{
				++hit;
				continue;
			}

			for( int j=0; j<4; ++j )
			{
				blow += v[0][i] == v[1][j];
			}
		}

		std::cout << hit << ' ' << blow << '\n';
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<int> deqa;
    std::deque<int> deqb;
    int a,b,hit,blow;
    hit = 0;
    blow = 0;
    while (cin >> a) {
        int tmp = a;
        deqa.emplace_back(tmp);
        for (int i=0;i<3;i++) {
            cin >> a;
            deqa.emplace_back(a);
        }
        for (int j=0;j<4;j++) {
            cin >> b;
            deqb.emplace_back(b);
        }
        int a1 = deqa[0];
        int b1 = deqb[0];
        int a2 = deqa[1];
        int b2 = deqb[1];
        int a3 = deqa[2];
        int b3 = deqb[2];
        int a4 = deqa[3];
        int b4 = deqb[3];
        if (a1==b1) {
            hit++;
        } else if (b1==a2 || b1==a3 || b1==a4) {
            blow++;
        }
        if (a2==b2) {
            hit++;
        } else if (b2==a1 || b2==a3 || b2==a4) {
            blow++;
        }
        if (a3==b3) {
            hit++;
        } else if (b3==a1 || b3==a2 || b3==a4) {
            blow++;
        }
        if (a4==b4) {
            hit++;
        } else if (b4==a1 || b4==a2 || b4==a3) {
            blow++;
        }
        cout << hit << " " << blow << endl;
        
        deqa.clear();
        deqb.clear();
        hit = 0;
        blow = 0;
    }
}

C++: #include<iostream>

using namespace std;

int main(){
	int a[4], b[4];

	while (1){
		for (int i = 0; i < 4; i++)
			cin >> a[i];
		for (int i = 0; i < 4; i++)
			cin >> b[i];

		//hit
		int hit = 0;
		for (int i = 0; i < 4; i++)
			hit += (a[i] == b[i]);


		//blow
		int blow = 0;
		for (int i = 0; i < 4; i++)
			blow +=( (a[i] == b[0]) || (a[i] == b[1]) || (a[i] == b[2]) || (a[i] == b[3]));

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

	return 0;

}

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

int main(void){
  int a[4];
  int b[4];
  int hit, blow;
  while(cin >> a[0] >> a[1] >> a[2] >> a[3]){
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    hit = blow = 0;
    for(int i = 0; i < 4; i++){
      if(a[i] == b[i])
	hit++;
      else
	for(int j = 0; j < 4; j++)
	  if(a[j] == b[i])
	    blow++;
    }
    cout << hit << ' ' << blow << endl;
  }
  return 0;
}

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

int main(){
  std::array<int, 4> a = {};
  std::array<int, 4> b = {};
  int hit = 0;
  int blow = 0;
  int N = 0;

  while(N <= 50 && std::cin >> a[0] >> a[1] >> a[2] >> a[3] && std::cin >> b[0] >> b[1] >> b[2] >> b[3]){
    for(int i = 0;i < 4;++i){
      for(int j = 0;j < 4;++j){
          if(a[i] == b[j] && i == j)
              ++hit;
          if(a[i] == b[j] && i != j)
              ++blow;
            }
        }
    std::cout << hit << " " << blow << std::endl;

    hit = 0;
    blow = 0;
    ++N;
  }
}

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

int main(){
    int array[4][2] = {0};
    int hit = 0;
    int blow = 0;
    while (cin>>array[0][0]>>array[1][0]>>array[2][0]>>array[3][0]){
        cin >> array[0][1]>>array[1][1]>>array[2][1]>>array[3][1];
        hit = 0;
        blow = 0;
        for (int i = 0; i < 4; i++){
            if (array[i][0] == array[i][1]) {
                hit++;
            }
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if (array[i][0] == array[j][1]) {
                    if (array[i][0] != array[i][1]) {
                        blow++;
                    }
                }
            }
        }
        cout << hit << " " << blow << endl;
        //printf("%d %d\n",hit,blow);
    }
    return 0;
}

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

int main(){
	int a[4], b[4];
	int hit, blow;
	char c;

	while (cin >> c){
		cin >> a[0] >> a[1] >> a[2] >> a[3];
		cin >> b[0] >> b[1] >> b[2] >> b[3];

		hit = 0; blow = 0;

		for (int i = 0; i < 4; ++i){
			for (int j = i; j < 4; ++j){
				if (a[i] == b[j])
					++blow;
			}
		}

		for (int i = 0; i < 4; ++i){
			if (a[i] == b[i]){
				++hit;
				--blow;
			}
		}

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

	}
	return 0;
}

C++: #include<iostream>

using namespace std;
int main(){
    int a[4],b[4];
   
	for(int i=0;i<4;i++)
	cin >> a[i];
	
	for(int i=0;i<4;i++)
	cin >> b[i];
    int hit=0,blow=0;
    if(a[0] == b[0])hit++;
    if(a[1] == b[1])hit++;
    if(a[2] == b[2])hit++;
    if(a[3] == b[3])hit++;
    if(a[0] == b[1])blow++;
    if(a[1] == b[2])blow++;
    if(a[2] == b[3])blow++;
    if(a[1] == b[0])blow++;
    if(a[2] == b[1])blow++;
    if(a[2] == b[0])blow++;
    if(a[3] == b[2])blow++;
    if(a[3] == b[1])blow++;
    if(a[3] == b[0])blow++;
    if(a[0] == b[2])blow++;
    if(a[1] == b[3])blow++;
    if(a[0] == b[3])blow++;
    cout << hit << " " << blow << "\n";
    return 0;
    }

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

int main(){
	int a[4],b[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3]){
		cin >> b[0] >> b[1] >> b[2] >> b[3];
		
		int c[4], hit, blow;
		for(int i = 0; i < 4; i++){
			if(a[i] == b[i]){
				hit ++;
				c[i] = 1;
			}
		}
		
		for(int i = 0; i < 4; i++){
			if(c[i] == 1) continue;
			else{
				for(int j = 0; j < 4; j++){
					if(a[i] = b[j]){
						blow ++;
					}
				}
			}
		}
		
		cout << hit << " " << blow << endl;
	}
}

C++: #include <iostream>
#include <array>
void counter(unsigned int* n_a,unsigned int* n_b,int* hit,int* blow);

int main() {

	std::array<unsigned int, 4> n_a;//selection of "A"
	std::array<unsigned int, 4> n_b;//selection of "B"

	while (std::cin) {
		std::cin >> n_a[0] >> n_a[1] >> n_a[2] >> n_a[3];
		std::cin >> n_b[0] >> n_b[1] >> n_b[2] >> n_b[3];

		int hit = 0;//factor and place are same
		int blow = 0;//only factor is same

		counter(n_a.data(),n_b.data(),&hit,&blow);

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

}

/*This function is a counter for "hit" and "blow".*/
void counter(unsigned int* n_a,unsigned int* n_b,int* hit,int* blow) {
	
	for (int i = 0; i < 4; ++i){
		for (int j = 0; j < 4; ++j){
			//the case of factor and place are same
			if (n_a[i] == n_b[j] && i == j) {
				*hit = *hit + 1;
			}
			//the case of only factor is same
			else if (n_a[i] == n_b[j]) {
				*blow = *blow + 1;
			}
			//otherwise
			else {
				//nothing to do
			}
		}
	}

}

C++: #include<stdio.h>

int main()
{
int p[4]={};
int q[4]={};
int x,H,B;
H=0;B=0;
for(int i=0;i<4;i++)
{scanf("%d",&x);p[i]=x;}
for(int i=0;i<4;i++)
{scanf("%d",&x);q[i]=x;}
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
{if(p[i]==q[j]){
	if(i==j)H++;
    else if(i!=j)B++;
}}
printf("%d %d\n",H,B);
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int a[4],b[4],h,w,i,j;
while(cin>>a[0]){
h=w=0;
for(i=1;i<4;i++)cin>>a[i];
for(i=0;i<4;i++)cin>>b[i];
for(i=0;i<4;i++){
for(j=0;j<4;j++){
if(i==j&&a[i]==b[j])h++;
else if(a[i]==b[j])w++;
}
}
cout<<h<<" "<<w<<endl;
}
return 0;
}