zzulioj 1020: Sort two integers

Title description
Input two integers x, y from the keyboard, and output their values ​​in ascending order.
Input
Input two integers x, y.
Output
Output their values ​​in ascending order. The data is separated by spaces.
Sample input Copy
20 16
sample output Copy
16 20
prompt
...
if else;

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

?:;

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

Guess you like

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