[cpp] c++

Viewer

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7. void mat1(int a,int b,int c)
  8. {
  9.         int m;
  10.         m = (a+b)*c/(b+4);
  11.         cout<<"m : "<<m;
  12.  
  13.  
  14.  
  15. }
  16. void mat2(int a,int b,int c)
  17. {
  18.         int m;
  19.         m = (c-a)*b/a+1;
  20.         cout<<"m : "<<m;
  21.  
  22. }
  23.  
  24. int main()
  25. {
  26.  
  27.         int a;
  28.         int b;
  29.         int c;
  30.         cout<<"a :";
  31.         cin>>a;
  32.         cout<<endl;
  33.  
  34.         cout<<"b: ";
  35.         cin>>b;
  36.         cout<<endl;
  37.  
  38.         cout<<"c: ";
  39.         cin>>c;
  40.         cout<<endl;
  41.  
  42.         if (a<b<c)
  43.         {
  44.                 mat1(a,b,c);
  45.         }
  46.         else if (b<a<c)
  47.         {
  48.                 mat2(a,b,c);
  49.         }
  50.         else {
  51.  
  52.                 int m;
  53.                 m = (a+b+c)/(2*b+c);
  54.                 cout<<endl;
  55.                 cout<<"m: "<<m;
  56.         }
  57.  
  58.  
  59.         return 0;
  60.  
  61.  
  62. }

Editor

You can edit this paste and save as new:


File Description
  • c++
  • Paste Code
  • 03 Dec-2023
  • 852 Bytes
You can Share it: