1021: Maximum value of three integers

Title description
Input three integers x, y and z from the keyboard and find the largest number among them.
Enter
Enter three integers, separated by spaces.
Output
Output the largest integer.
Sample input Copy
20 16 18
Sample output Copy
20
prompt
...

Comparison method:

#include<stdio.h>
int main()
{
    
    
	int x, y, z, max;
	scanf("%d%d%d",&x,&y,&z);
	max=x;
	if(y>max)
	  max=y;
	  if(z>max)
	    max=z;
	printf("%d\n",max);
	return 0;
 } 

? :method:

#include<stdio.h>
int main()
{
    
    
	int x, y, z, max;
	scanf("%d%d%d",&x,&y,&z);
	max=x>=y?x:y;
	max=max>=z?max:z;
	printf("%d\n",max);
	return 0;
}

Guess you like

Origin blog.csdn.net/m0_53024529/article/details/112729620