Advertisement
STANAANDREY

ad 2 nr mari

Feb 13th, 2020
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. void aduna(int a[], int b[], int rezultat[])
  2. {
  3.     int tran = 0, maxi, c, i;
  4.     if (a[0] < b[0])
  5.     {
  6.         maxi = b[0];
  7.         for (i = a[0] + 1; i <= b[0]; i++)
  8.             a[i] = 0;
  9.     }
  10.     else
  11.     {
  12.         maxi = a[0];
  13.         for ( i = b[0] + 1; i <= a[0]; i++)
  14.             b[i] = 0;
  15.     }
  16.     for (i = 1; i <= maxi; i++)
  17.     {
  18.      c = a[i] + b[i] + tran;
  19.      rezultat[i] = c % 10;
  20.      tran = c / 10;
  21.     }
  22.     if (tran)
  23.       rezultat[i] = tran;
  24.     else
  25.         i--;
  26.     rezultat[0] = i;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement