Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("sumaxl.in");
  5. ofstream fout("sumaxl.out");
  6. typedef int Huge[101];
  7. void AtribValue(Huge x,unsigned long y)
  8. {
  9. x[0]=0;
  10. while(y)
  11. {
  12. x[0]++;
  13. x[x[0]]=y%10;
  14. y/=10;
  15. }
  16.  
  17. }
  18. void Adunare(Huge x,Huge y)
  19. {
  20. int i,t=0;
  21. if(x[0]<y[0])
  22. {
  23. x[0]=y[0];
  24. }
  25. for(i=1;i<=x[0];i++,t/=10)
  26. {
  27. x[i]=(t+=x[i]+y[i])%10;
  28. }
  29. if(t)
  30. x[++x[0]]=t;
  31. }
  32. Huge S,Y;
  33. int main()
  34. {
  35. int y,i;
  36. fin>>S[0];
  37. for(i=S[0];i>=1;i--)
  38. fin>>S[i];
  39. fin>>y;
  40. AtribValue(Y,y);
  41. Adunare(S,Y);
  42. for(i=S[0];i>=1;i--)
  43. fout<<S[i];
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement