Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4.  
  5. struct Party{
  6. int score;
  7. string name;
  8. };
  9.  
  10. int main(){
  11. int partyNum,gusses;
  12. cin>>partyNum>>gusses;
  13. Party * arr=new Party[partyNum];
  14.  
  15. for(int i=0;i<partyNum;i++){
  16. float temp;
  17. cin>>arr[i].name>>temp;
  18. arr[i].score=temp*10;
  19. }
  20. for(int i=0;i<gusses;i++)
  21. {
  22. float sum=0;
  23. string temp="";
  24. while(true)
  25. {
  26. cin>>temp;
  27. if((temp=="="||temp==">"||temp=="<"||temp==">="||temp=="<="))
  28. break;
  29. if(temp!="+")
  30. {
  31. for(int j=0;j<partyNum;j++)
  32. {
  33. if(arr[j].name==temp)
  34. {
  35. sum+=arr[j].score;
  36. break;
  37. }
  38. }
  39. }
  40. }
  41. int score;
  42. cin>>score;
  43. score*=10;
  44. if(temp=="="&&sum==score)
  45. {
  46. cout<<"Guess #"<<i+1<<" "<<"was correct."<<endl;
  47. }
  48. else if(temp=="="&&sum!=score){
  49. cout<<"Guess #"<<i+1<<" "<<"was incorrect."<<endl;
  50. }
  51. else if(temp==">"&&sum>score){
  52. cout<<"Guess #"<<i+1<<" "<<"was correct."<<endl;
  53. }
  54.  
  55. else if(temp==">"&&sum<=score){
  56. cout<<"Guess #"<<i+1<<" "<<"was incorrect."<<endl;
  57. }
  58.  
  59. else if(temp=="<"&&sum<score){
  60. cout<<"Guess #"<<i+1<<" "<<"was correct."<<endl;
  61. }
  62.  
  63. else if(temp=="<"&&sum>=score){
  64. cout<<"Guess #"<<i+1<<" "<<"was incorrect."<<endl;
  65. }
  66. else if(temp==">="&&sum>=score){
  67. cout<<"Guess #"<<i+1<<" "<<"was correct."<<endl;
  68. }
  69. else if(temp==">="&&sum<score){
  70. cout<<"Guess #"<<i+1<<" "<<"was incorrect."<<endl;
  71. }
  72. else if(temp=="<="&&sum<=score){
  73. cout<<"Guess #"<<i+1<<" "<<"was correct."<<endl;
  74. }
  75. else if(temp=="<="&&sum>score){
  76. cout<<"Guess #"<<i+1<<" "<<"was incorrect."<<endl;
  77. }
  78.  
  79.  
  80. }
  81. return 0;
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement