Submission details
Task:ModAdd
Sender:guq2
Submission time:2016-09-24 13:51:41 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:15:29: error: 'memset' was not declared in this scope
   memset(ans, 0, sizeof(ans));
                             ^
input/code.cpp:16:14: error: 'strlen' was not declared in this scope
   if(strlen(a)<strlen(b)) swap(a,b);
              ^
input/code.cpp:17:20: error: 'strlen' was not declared in this scope
   int alen=strlen(a);
                    ^

Code

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const int MAX=65;

int main()
{
	ios::sync_with_stdio(0);
	char a[MAX], b[MAX];
	char ans[MAX];
	while(scanf("%s %s", a, b)!=EOF){
		memset(ans, 0, sizeof(ans));
		if(strlen(a)<strlen(b)) swap(a,b);
		int alen=strlen(a);
		int blen=strlen(b);
		int tmp = 0;
		for(int i=0; i<alen; i++)
		{
			if(i<blen)
				tmp = a[alen-i-1]-'0'+b[blen-i-1]-'0';
			else
				tmp = a[alen-i-1]-'0';
			tmp = tmp>=10?tmp-10:tmp;
			ans[alen-i-1] = '0'+tmp;
		}
		int flag=0;
		for(int i=0; i<alen; i++){
			if(flag==0 && ans[i]=='0')
			{
				if(alen>1)
					continue;
			}
			else 
				flag=1;
			printf("%c", ans[i]);			
		}
		printf("\n");
	}	

	return 0;
}