Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void)
  5. {
  6.     int i, j, h;
  7.  
  8.     int a[] = {0, 4, 5, 9, 2, 7, 4, 9, 5, 7, 1, 6, 2, 0, 3, 0};
  9.     int b[] = {0, 2, 7, 8, 4, 9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  10.     int *result = (int *) malloc(17*sizeof(int));
  11.  
  12.     for (i = 0; i < sizeof(result); i++) {
  13.         printf("result[i-1]");
  14.  
  15.         if (a[i] + b[i] > 9){
  16.             result[i] = a[i] + b[i] - 10;
  17.             result[i-1] += 1;
  18.         }
  19.         else{
  20.             result[i] = a[i] + b[i];
  21.         }
  22.        
  23.         for (j = 0; h < sizeof(result); j++) {
  24.             if (result[j] > 9){
  25.                 result[j] -= 10;
  26.                 result[j-1] += 1;
  27.             }  
  28.         }
  29.     }
  30.    
  31.     printf("Result: ");
  32.     for (h = 0; h < sizeof(result); h++) {
  33.         printf("%d", result[h]);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement