Skip to content

Instantly share code, notes, and snippets.

@imakin
Created April 9, 2015 11:10
Show Gist options
  • Save imakin/12ea85b7db780b8e83b9 to your computer and use it in GitHub Desktop.
Save imakin/12ea85b7db780b8e83b9 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main() {
char A[200];
char B[200];
char T[200];
size_t lenA,lenB,maxLen;
int i;
int digitA,digitB,digitH,carry;
scanf("%s",A);lenA = strlen(A);
scanf("%s",B);lenB = strlen(B);
if (lenB>lenA)
{
maxLen = lenB;
for (i=0; i<maxLen-lenA; i++)
T[i] = '0';
for (i=maxLen-lenA; i<maxLen; i++)
T[i] = A[lenA-maxLen+i];
T[maxLen] = '\0';
printf("%s\n",T);
printf("%s\n",B);
}
else
{
maxLen = lenA;
for (i=0; i<maxLen-lenB; i++)
T[i] = '0';
for (i=maxLen-lenB; i<maxLen; i++)
T[i] = B[lenB-maxLen+i];
T[maxLen] = '\0';
printf("%s\n",A);
printf("%s\n",T);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment