Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. main(){
  8.     double a[4];
  9.     for(int i=0; i<3; i++)
  10.     {
  11.         a[i]=0;
  12.         cout<<"Введите числа"<<endl;
  13.         cin>>a[i];
  14.     }
  15.     char c[3];
  16.     for (int i = 0; i < 2; i++)
  17.     {
  18.         c[i]='+';
  19.         cout<<"Введите действия"<<endl;
  20.         cin>>c[i];
  21.     }
  22.         cout<<a[0]<<c[0]<<a[1]<<c[1]<<a[2]<<"=\t";
  23.         double p=0;
  24.         if(c[0]=='+')
  25.             p=a[0]+a[1];
  26.         if(c[0]=='*')
  27.             p=a[0]*a[1];
  28.         if(c[0]=='-')
  29.             p=a[0]-a[1];
  30.         if(c[0]=='/')
  31.             p=a[0]/a[1];
  32.         if(c[1]=='+')
  33.             p=p+a[2];
  34.         if(c[1]=='*')
  35.             p=p*a[2];
  36.         if(c[1]=='-')
  37.             p=p-a[2];
  38.         if(c[1]=='/')
  39.             p=p/a[2];
  40.         cout<<p<<endl;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement