if (a > b)
{
max = a;
min = b;
}
else
{
max = b;
min =a;
}
if (max < c)
max = c;
else if (min > c)
min =c;
if (max < d)
max = d;
else if (min > d)
min = d;
#2
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("max=%d\n",max(max(a,b),max(c,d)));
printf("min=%d\n",min(min(a,b),min(c,d)));
return 0;
}
库函数有min和max的
#3
//C++语言写一个求四个数的最大值最小值,在主函数中怎么写呀
#include <stdio.h>
main() {
int a,b,c,d,max,min;
scanf("%d%d%d%d",&a,&b,&c,&d);
if (a > b)
{
max = a;
min = b;
}
else
{
max = b;
min =a;
}
if (max < c)
{
max = c;
}
else if (min > c)
{
min =c;
}
if (max < d)
{
max = d;
}
else if (min > d)
{
min = d;
}
printf("max=%d min=%d",max,min);
return 0;
}
#4
C++11:
std::max({a, b, c, d})
std::min({a, b, c, d})
#5
谢提醒
#6
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("max=%d\n",max(max(a,b),max(c,d)));
printf("min=%d\n",min(min(a,b),min(c,d)));
return 0;
}
库函数有min和max的
up主 呸 版主我这个掉了一句话抱歉
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("max=%d\n",max(max(a,b),max(c,d)));
printf("min=%d\n",min(min(a,b),min(c,d)));
return 0;
}
#7
谢谢你们啦!
#8
#include<stdio.h>
int main()
{
int max(int,int);
int min(int,int);
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("max=%d\n",max(max(a,b),max(c,d)));
printf("min=%d\n",min(min(a,b),min(c,d)));
return 0;
}
//以下是调用的函数
int max(int x, int y)
{
if(x>y)
return (x);
else
return (y);
}
int min(int x, int y)
{
if(x<y)
return (x);
else
return (y);
}
#1
if (a > b)
{
max = a;
min = b;
}
else
{
max = b;
min =a;
}
if (max < c)
max = c;
else if (min > c)
min =c;
if (max < d)
max = d;
else if (min > d)
min = d;
#2
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("max=%d\n",max(max(a,b),max(c,d)));
printf("min=%d\n",min(min(a,b),min(c,d)));
return 0;
}
库函数有min和max的
#3
//C++语言写一个求四个数的最大值最小值,在主函数中怎么写呀
#include <stdio.h>
main() {
int a,b,c,d,max,min;
scanf("%d%d%d%d",&a,&b,&c,&d);
if (a > b)
{
max = a;
min = b;
}
else
{
max = b;
min =a;
}
if (max < c)
{
max = c;
}
else if (min > c)
{
min =c;
}
if (max < d)
{
max = d;
}
else if (min > d)
{
min = d;
}
printf("max=%d min=%d",max,min);
return 0;
}
#4
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("max=%d\n",max(max(a,b),max(c,d)));
printf("min=%d\n",min(min(a,b),min(c,d)));
return 0;
}
库函数有min和max的
C++11:
std::max({a, b, c, d})
std::min({a, b, c, d})
#5
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("max=%d\n",max(max(a,b),max(c,d)));
printf("min=%d\n",min(min(a,b),min(c,d)));
return 0;
}
库函数有min和max的
C++11:
std::max({a, b, c, d})
std::min({a, b, c, d})
谢提醒
#6
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("max=%d\n",max(max(a,b),max(c,d)));
printf("min=%d\n",min(min(a,b),min(c,d)));
return 0;
}
库函数有min和max的
up主 呸 版主我这个掉了一句话抱歉
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("max=%d\n",max(max(a,b),max(c,d)));
printf("min=%d\n",min(min(a,b),min(c,d)));
return 0;
}
#7
谢谢你们啦!
#8
#include<stdio.h>
int main()
{
int max(int,int);
int min(int,int);
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("max=%d\n",max(max(a,b),max(c,d)));
printf("min=%d\n",min(min(a,b),min(c,d)));
return 0;
}
//以下是调用的函数
int max(int x, int y)
{
if(x>y)
return (x);
else
return (y);
}
int min(int x, int y)
{
if(x<y)
return (x);
else
return (y);