Facebook
From ds, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 150
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     char s[101],c,cs[100],cuv[51][51]={};
  8.     int i,j,nr=0,nr2=0,n=2;
  9.     for(int x=0; x<n; x++)
  10.     {
  11.         cin>>s;
  12.         strcpy(cuv[x],s);
  13.         nr=0,nr2=0;
  14.         for(i=0; s[i]>='0'&&s[i]<='9'; i++)
  15.         {
  16.             nr=nr*10+s[i]-'0';
  17.  
  18.         }
  19.         c=s[i];
  20.         strcpy(s,s+i+1);
  21.         for(i=0; i<strlen(s); i++)
  22.             nr2=nr2*10+s[i]-'0';
  23.         if(c=='*')
  24.             cout<<cuv[x]<<"="<<nr*nr2<<endl;
  25.         else if(c=='+')
  26.             cout<<nr+nr2;
  27.         n--;
  28.     }
  29.  
  30.     return 0;
  31. }
  32.