7-12 Who is the winner (10 points)

The entertainment program of a certain TV station has a performance review session, each time two artists are arranged to perform, and their victory or defeat is determined by the two parts of audience voting and 3 judges voting. The rule is: if an artist has a high number of audience votes and is approved by at least one judge, the artist wins; or an artist has a low number of audience votes but is approved by all the judges, he can also win. The program guarantees that the number of viewers voting is odd, so there is no tie vote. For this question, please use the program to judge who is the winner.

Input format:
Input the first line to give 2 positive integers Pa and Pb not exceeding 1000, which are the number of audience votes obtained by artist a and artist b respectively. The title guarantees that these two numbers are not equal. Then the second line gives the voting results of the 3 judges. The number 0 means voting for a, and the number 1 means voting for b, separated by a space.

Output format:
Output the winner in the following format:

The winner is x: P1 + P2

Where x is the letter representing the winner, P1 is the number of audience votes the winner gets, and P2 is the number of judges votes the winner gets.
Input sample:

327 129
1 0 1

Sample output:

The winner is a: 327 + 1
#include<stdio.h>
int main(void)
{
    
    
	int Pa,Pb,a1,b1,x1,x2,x3;
	scanf("%d %d",&Pa,&Pb);
	scanf("%d %d %d",&x1,&x2,&x3);
	a1=x1+x2+x3;
	b1=3-a1;
	if((Pa>Pb&&b1>=1)||(Pa<Pb&&b1==3)){
    
    
		printf("The winner is a: %d + %d",Pa,b1);
	}
	else{
    
    
		printf("The winner is b: %d + %d",Pb,a1);
	}
	return 0;
}

Guess you like

Origin blog.csdn.net/weixin_45814538/article/details/108886127