範例程式碼 uva340
//uva340
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
bool case_break(int g[], int n){
for (int i = 0 ; i < n ; i++){
if (g[i]){
return false;
}
}
return true;
}
int main(){
int n, s[1001], g[1001], game = 1;
while (cin >> n && n != 0){
for (int i = 0 ; i < n ; i++)
cin >> s[i];
while (1){
int s_m = 0, w_m = 0;
int count_s[10] = {0}, count_g[10] = {0};
for (int i = 0 ; i < n ; i++)
cin >> g[i];
if (case_break(g, n))
break;
for (int i = 0 ; i < n ; i++){
if (s[i] == g[i])
s_m += 1;
else {
count_s[s[i]] += 1;
count_g[g[i]] += 1;
}
}
for (int i = 1 ; i <= 9 ; i++)
w_m += min(count_s[i], count_g[i]);
}
game += 1;
}
}