About Me

About Me : I have been working as a Software Engineer for various international companies for four years.Currently, I am working as a full stack Javascript developer in Petronas(Malaysia).

Skills

Skills • Javascript •Typescript •Python •C •Java •ReactJs • Redux • VueJs • NestJs • React Testing Library • Django• PostgreSQL • MySQL • NodeJs • Git • Docker • Jira • Visual Studio Code • Slack

শুক্রবার, ৫ ডিসেম্বর, ২০১৪

UVA SOLUTION :424 - Integer Inquiry solution

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include<iostream>
#include<cmath>
#include<map>
#include<string>
#include<cstring>
using namespace std;
string sum(string su, string ss)
{
int l1 = su.length();
int l2 = ss.length();
string res;
int rem = 0;
for (int i = l1 - 1, j = l2 - 1;; i--, j--)
{
if (i < 0 && j < 0) break;
if (i >= 0 && j >= 0)
{
int sum = (su[i] - '0') + (ss[j] - '0') + rem;
if (sum>9)
{
res += ((sum % 10) + '0');
rem = sum / 10;
}
else
{
res += (sum + '0');
rem = 0;
}
}
else if (i >= 0 && j < 0)
{
int sum = (su[i] - '0')  + rem;
if (sum>9)
{
res += ((sum % 10) + '0');
rem = sum / 10;
}
else
{
res += (sum + '0');
rem = 0;
}

}
if (i < 0 && j >= 0)
{
int sum =  (ss[j] - '0') + rem;
if (sum>9)
{
res += ((sum % 10) + '0');
rem = sum / 10;
}
else
{
res += (sum + '0');
rem = 0;
}
}
}
if (rem > 0) res += (rem + '0');
string re;
for (int i = res.length() - 1; i >= 0; i--) re += res[i];
return re;


}
int main() {

string ss,su;
bool flag = false;
while (cin >> ss)
{
if (ss[0] == '0')
{
cout << su << endl;
break;
}
if (flag == false)
{
su = ss;
}
else
{
string s=sum (su, ss);
su = s;
//cout << s << endl;
}

flag = true;
}



return 0;
}

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন