20191116-SWITCH
-
#include "stdafx.h"
-
#include "cstdio"
-
#include "iostream"
-
using namespace std;
-
int main(){
-
int a,b,c,d;
-
cin>>a>>b>>c>>d;
-
int m=a;
-
if(m>b)
-
m=b;
-
if(m>c)
-
m=c;
-
if(m>d)
-
m=d;
-
cout<<m<<endl;}
-
这是解法1,运行结果如下:
-
-
-
-
-
#include "stdafx.h"
-
#include "cstdio"
-
#include "iostream"
-
using namespace std;
-
int main(){
-
int a,b,c,d;
-
cin>>a>>b>>c>>d;
-
int m=a;
-
if(m>b)
-
m=b;
-
if(m>c)
-
m=c;
-
if(m>d)
-
m=d;
-
cout<<m<<endl;}
-
这是解法2,运行结果如下:
-
-
-
#include "stdafx.h"
-
#include "cstdio"
-
#include "iostream"
-
#include "algorithm"//sort
-
using namespace std;
-
int e[4];
-
int main(){
-
int a,b,c,d;
-
cin>>a>>b>>c>>d;
-
e[0]=a;e[1]=b;e[2]=c;e[3]=d;
-
sort(e,e+4);
-
cout<<e[0]<<endl;}
-
这是解法3,运行结果如下:
-