fork(2) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. ios_base::sync_with_stdio(false);
  7. int t, i, j, k, x, temp;
  8. int num1[10000], num2[10000];
  9. char c;
  10. bool f = true;
  11. cin >> t;
  12.  
  13. while (t--)
  14. {
  15. for (i = 0; i < 10000; i++)
  16. {
  17. num1[i] = 0;
  18. num2[i] = 0;
  19. }
  20. i = 0;
  21. j = 0;
  22. while (!isspace(c = getchar()) && c!=EOF)
  23. num1[i++] = c - '0';
  24. while (!isspace(c = getchar()) && c!=EOF)
  25. num2[j++] = c - '0';
  26. x = i > j ? i : j;
  27. temp = 0;
  28. for (k = 0; k < x; k++)
  29. {
  30. i = temp + num1[k] + num2[k];
  31. if (f)
  32. {
  33. if (i % 10 != 0)
  34. {
  35. f = false;
  36. cout << i % 10;
  37. }
  38. }
  39. else cout << i % 10;
  40. temp = i / 10;
  41. }
  42. if (temp != 0)
  43. cout << temp;
  44. cout << endl;
  45. f = true;
  46. }
  47. return 0;
  48. }
Success #stdin #stdout 0s 3480KB
stdin
1
24 1
stdout