C语言的问题 急救 谢谢!!

来源:百度知道 编辑:UC知道 时间:2024/06/03 07:22:19
Write the definition of a function minMax that has five parameters. The first three parameters are integers. The last two are set by the function to the largest and smallest of the values of the first three parameters.

The function does not return a value.

The function can be used as follows:

      int a=31, b=5, c=19, big, small;
      minMax(a,b,c,&big,&small);
            /* big is now 31 */
            /* small is now 5 */

不是语言问题 我编程很差 请前辈们多多指教谢谢!!

void minMax(int a,int b,int c,int *big,int *small)
{
if(a>b)
{
*big=a;
*small=b;
}else
{
*big=b;
*small=a;
}
*big=c>*big?c:*big;
*small=c<*small?c:*small;
}

int a=31, b=5, c=19, big, small;
minMax(a,b,c,&big,&small)
{
big=a>b?a:b;
big=big>c?big:c;
small=a>b?b:a;
small=small>c?c:small;
}
/* big is now 31 */
/* small is now 5 */

# include<stdio.h>
void minMax(int a,int b,int c)
{ int min,max
if(a>b) //先比较a和b 的值
{ //如果a比b大那么比较a和c
if(a>c) //如果a>b>c
{
max=a; //最大的为a
if(b>c) min=c;
else min=b;
}
else
{
max=c;
min=b;
}
}
else
{ //如果a比b小那么比较a和c
if(a>c)
{
max=b;
min=c;
}