Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
accept#include<iostream> #include<math.h> using namespace std; int Getscore(double n) { if (n >= 0&&n <= 3) { return 100; } else if (n > 3&&n <= 6) { return 80; } else if (n > 6&&n <= 9) { return 60; } else if (n > 9&&n <= 12) { return 40; } else if (n > 12&&n <= 15) { return 20; } else if (n > 15) { return 0; } } int main() { double ax[3],ay[3]; double bx[3],by[3]; double r,ascore,bscore; int i; while(1) { ascore=0.0; bscore=0.0; for(i=0; i<3; i++) { cin >> ax[i] >> ay[i]; r = sqrt(pow(ax[i],2)+pow(ay[i],2)); ascore += Getscore(r); } for(i=0; i<3; i++) { cin >> bx[i] >> by[i]; r = sqrt(pow(bx[i],2)+pow(by[i],2)); bscore += Getscore(r); } if (ax[0]==-100) { break; } cout << "SCORE: " << ascore << " to " << bscore; if (ascore > bscore) { cout << ", PLAYER 1 WINS." << endl; } else if (ascore < bscore) { cout << ", PLAYER 2 WINS." << endl; } else if (ascore == bscore) { cout << ", TIE. " << endl; } } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator