For example, if there are 5 rounds and player A plays (in this order) 5, 3, 1, 3, 5 and player B plays 3, 3, 3, 3, 4, then the scoring for each round would be: A gets 5 points, no points, B gets 3 points, no points, B gets 9 points. The totals would be A: 5, B: 12.
In this problem you will be given card plays for both players and must determine the final scores.
Input
There will be multiple input instances. Each instance will be one game. The first line of input for a game will be an integer n <= 20. (A value of n = 0 terminates input.) The next two lines will each contain n integers between 1 and 5 inclusive indicating the cards played on each of n rounds. The first line are player A's card plays and the second line are player B's card plays.
Output
Each input instance should generate one line of output of the form:
A has a points. B has b points.
where the value of a and b are for you to determine. A blank line should separate output lines.
Sample Input
5
5 3 1 3 5
3 3 3 3 4
4
2 3 1 1
1 5 5 5
0
Sample Output
A has 5 points. B has 12 points.
A has 0 points. B has 21 points.
// ZOJ_1057.cpp : Defines the entry point for the console application. // #include <iostream> using namespace std; int main() { size_t num; bool boo=false; while(cin>>num){ if(num==0&&boo==false) break; int *a=new int[num]; int *b=new int[num]; int sum_a=0,sum_b=0,de; for(size_t i=0;i<num;++i) cin>>a[i]; for(size_t j=0;j<num;++j) cin>>b[j]; for(size_t k=0;k<num;++k){ de=a[k]-b[k]; if(de>=2) sum_a+=a[k]; if(de<=-2) sum_b+=b[k]; if(de==1){ if(a[k]!=2) sum_b=sum_b+a[k]+b[k]; if(a[k]==2) sum_b+=6; } if(de==-1){ if(a[k]!=1) sum_a=sum_a+a[k]+b[k]; if(a[k]==1) sum_a+=6; } } if(boo==true&&num!=0) cout<<endl; if(boo==true&&num==0) break; cout<<"A has "<<sum_a<<" points. "<<"B has "<<sum_b<<" points."<<endl; delete [] a; delete [] b; boo=true; } return 0; }