csansoon

P4.05 X46340 Function for the sum of the minimum and the

Oct 24th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int sum_min_max(int x, int y, int z){
  5.     int a,b;
  6.     if (x<=y&&x<=z) a=x;
  7.     else if (y<=x&&y<=z) a=y;
  8.     else a=z;
  9.     if (x>=y&&x>=z) b=x;
  10.     else if (y>=x&&y>=z) b=y;
  11.     else b=z;
  12.     a=a+b;
  13.     return a;}
  14.    
  15. int main(){
  16.     int a,b,c;
  17.     cout<<"A=";
  18.     cin>>a;
  19.     cout<<"B=";
  20.     cin>>b;
  21.     cout<<"C=";
  22.     cin>>c;
  23.     cout<<endl<<sum_min_max(a,b,c)<<endl;
  24.    
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment