Monday, June 30, 2014

TopCoder High School SRM 29 Level one - 250 pt - Reverse Sums solution

TopCoder High School SRM 29 Level one - 250 pt - Reverse Sums statement: http://community.topcoder.com/stat?c=problem_statement&pm=6557&rd=10653

TopCoder High School SRM 29 Level one - 250 pt - Reverse Sums editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm29

TopCoder High School SRM 29 Level one - 250 pt - Reverse Sums solution:

#include <iostream>
using namespace std;

class ReverseSums {
    public: int getSum(int n) {
        int m=0, k=0;
        m=0, k=n;
        while(n>0) {
            m=m*10+n%10;
            n/=10;
        }
        return m+k;
    }
};


No comments:

Post a Comment