Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- struct Party{
- int score;
- string name;
- };
- int main(){
- int partyNum,gusses;
- cin>>partyNum>>gusses;
- Party * arr=new Party[partyNum];
- for(int i=0;i<partyNum;i++){
- float temp;
- cin>>arr[i].name>>temp;
- arr[i].score=temp*10;
- }
- for(int i=0;i<gusses;i++)
- {
- float sum=0;
- string temp="";
- while(true)
- {
- cin>>temp;
- if((temp=="="||temp==">"||temp=="<"||temp==">="||temp=="<="))
- break;
- if(temp!="+")
- {
- for(int j=0;j<partyNum;j++)
- {
- if(arr[j].name==temp)
- {
- sum+=arr[j].score;
- break;
- }
- }
- }
- }
- int score;
- cin>>score;
- score*=10;
- if(temp=="="&&sum==score)
- {
- cout<<"Guess #"<<i+1<<" "<<"was correct."<<endl;
- }
- else if(temp=="="&&sum!=score){
- cout<<"Guess #"<<i+1<<" "<<"was incorrect."<<endl;
- }
- else if(temp==">"&&sum>score){
- cout<<"Guess #"<<i+1<<" "<<"was correct."<<endl;
- }
- else if(temp==">"&&sum<=score){
- cout<<"Guess #"<<i+1<<" "<<"was incorrect."<<endl;
- }
- else if(temp=="<"&&sum<score){
- cout<<"Guess #"<<i+1<<" "<<"was correct."<<endl;
- }
- else if(temp=="<"&&sum>=score){
- cout<<"Guess #"<<i+1<<" "<<"was incorrect."<<endl;
- }
- else if(temp==">="&&sum>=score){
- cout<<"Guess #"<<i+1<<" "<<"was correct."<<endl;
- }
- else if(temp==">="&&sum<score){
- cout<<"Guess #"<<i+1<<" "<<"was incorrect."<<endl;
- }
- else if(temp=="<="&&sum<=score){
- cout<<"Guess #"<<i+1<<" "<<"was correct."<<endl;
- }
- else if(temp=="<="&&sum>score){
- cout<<"Guess #"<<i+1<<" "<<"was incorrect."<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement