首页 > 试题广场 >

有3个整数a,b,c,由键盘输入,输出其中最大的数。

[问答题]
有3个整数a,b,c,由键盘输入,输出其中最大的数。
#include<stdio.h>
#include<math.h>
int main()
{
 int a,b,c;
 int temp,max;
 scanf("%d,%d,%d",&a,&b,&c);
    temp=a>b?a:b;
 max=temp>c?a:c;
    printf("%d\n",max);
 return 0;
}
发表于 2020-02-05 16:26:34 回复(0)
int a,b,c;
int temp,max;
scanf("%d,%d,%d",&a,&b,&c);
temp=a>b?a:b;
max=temp>c?a:c;
printf("%d\n",max);
发表于 2019-09-25 16:35:46 回复(0)
1.<br /> <pre class="prettyprint lang-java">#include &lt;stdio.h&gt; int main( ) { int a,b,c; printf(“请输入三个整数:"); scanf("%d,%d,%d",&amp;a,&amp;b,&amp;c); if(a&lt;b) if(b&lt;c) printf("max=%d\n",c); else printf("max=%d\n",b); else if(a&lt;c) printf("max=%d\n",c); else printf("max=%d\n",a); return 0; }</pre> 2.<br /> <pre class="prettyprint lang-html">#include &lt;stdio.h&gt; int main( ) {int a,b,c,temp,max; printf(“请输入三个整数:"); scanf("%d,%d,%d",&amp;a,&amp;b,&amp;c); temp=(a&gt;b)?a:b; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*将a和b中的大者存入temp中*/ max=(temp&gt;c)?temp:c; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/*将a和b中的大者与c比较,取最大者*/ printf("三个整数的最大数是%d\n",max); return 0; }</pre> <br /> <stdio.h><b) if(b<c)="" printf("max="%d\n&quot;,c);" else="" if(a<c)="" return="" 0;="" }="" 2.="" #include="" <stdio.h=""></b)></stdio.h>
编辑于 2018-08-23 10:15:28 回复(0)