输入两个整型数,计算并输出两个整数的最大值

发布时间 2023-04-27 00:40:40作者: cvjj

设计思路:应用if判断语句和选择结构来实现程序的运行。

代码:

#include<stdio.h>

int main()

{

  int a,b,max,ret;

  printf("Input a,b:");

  ret=scanf("%d,%d",&a,&b);

  if(ret!=2)

  {

    printf("Input date quantity or format error!\n");

    fflush(stdin);

  }

  else

  {

    max=a>b?:b;

    printf("max=%d\n",max);

  }

  return 0;

}

总结:if判断语句的熟练应用