Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main(){
- char a[10000];
- char b[10000];
- scanf("%s %s", &a, &b);
- char sum[10000];
- int lengthA = 0;
- int lengthB = 0;
- int i = 0;
- while(a[i]){
- i++;
- } lengthA = i;
- i = 0;
- while(b[i]){
- i++;
- } lengthB = i;
- char temp[10000];
- int aplusb;
- int carry = 0;
- int max = lengthA;
- int difference = abs(lengthA - lengthB);
- //poravnava
- if(lengthA>lengthB){
- for(i=0; i<lengthA; i++){
- temp[i+difference]=b[i];
- }
- for(i=0; i<=max; i++){
- aplusb = lengthA[max-i]+temp[max-i];
- if(carry == 1) aplusb++;
- if(aplusb>9){
- carry = 1;
- aplusb%=10;
- }
- sum[i]=aplusb;
- }
- }
- for(i=0; i<=max; i++){
- printf("%c", sum[i]);
- }
- /*
- if(lengthB>lengthA){
- max = lengthB;
- for(i=0; i<lengthB; i++){
- temp[i+difference]=a[i];
- }
- }*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement