TOPIC

Oi estou recebendo W.A. , porfavor me ajudem ;-;

_Darkalamiro_ asked 3 years ago

#include <bits/stdc++.h> //2557

using namespace std;

int main()
{

    string equa;
       while(getline(cin, equa))
       {
          char aux[7], au[4];
          int tam, res, num1, num2, o = 0;

         tam = equa.length();
           for(int i = 0; i < tam; i++)
           {

            if(equa[i] == 'R') au[0] = 'R';
                else if(equa[i] == 'L') au[0] = 'L';
                     else if(equa[i] == 'J') au[0] = 'J';

            if(isdigit(equa[i]))
            {
               aux[0] = equa[i];

                             if(o == 0) 
                 {
                     num1 = atoi(aux);
                     o = 1;
                 }

                              else

                if(o == 1)
                { 
                    num2 = atoi(aux);
                    o = 0;
                }
            }
           }

              if(au[0] == 'J' || au[0] == 'j')
              {
             res = num1 + num2;
              }
            else 
                 if(au[0] == 'R' || au[0] == 'L' || au[0] == 'r' || au[0] == 'l')
                 {
                res = num2 - num1;
                 }

        cout << res << endl;

       }        

}

Remember not post solutions. Your post may be reviewed by our moderators.

  • Ashraful Islam Emon replied 2 months ago

    please use this line >> #include // stdlib.h >

    and declare num1 and num2 at (atoi) scope; >> int num1,num2;