Advertisement
STANAANDREY

inmultire 2nr mari

Aug 12th, 2019
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. void inmulteste(int a[], int b[], int rezultat[])
  2. {
  3.     int i, j, t = 0;
  4.     rezultat[0] = a[0] + b[0] - 1;
  5.     for (i = 1; i <= a[0] + b[0]; i++)
  6.         rezultat[i] = 0;
  7.     for (i = 1; i <= a[0]; i++)
  8.         for (j = 1; j <= b[0]; j++)
  9.         rezultat[i + j - 1] += a[i] * b[j];
  10.  
  11.     for (i = 1; i <= rezultat[0]; i++)
  12.     {
  13.         t += rezultat[i];
  14.         rezultat[i] = t % 10;
  15.         t /= 10;
  16.     }
  17.     if (t)
  18.         rezultat[++rezultat[0]] = t;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement