Help with coding


#1

What is this in Python and how do you solve it?
*

  • /

int calc(string A)
{
int i, n, ans = 0, p = 0;
n = A.length() - 1;

 for(i = n; i >= 0; i--)
 {
      if (numeral(A[i]) >= p)
           ans = ans + numeral(A[i]);
      else
           ans = ans - numeral(A[i]);

      p = numeral(A[i]);
 }
 return ans;

}


#2

What’s stopping you from translating that yourself? Doesn’t seem like you tried. Ask about whatever is giving you trouble instead, so that you can write the code yourself.


#3

Also, is this for roman numbers? you-kind-of-left-that-out


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.