fork download
  1. #include <stdio.h>
  2.  
  3. int StLen(char *s, int *outsl, int it)
  4. {
  5. while (s[it] != '\0') {if (*outsl += 1, it++){}}
  6. }
  7. int npwr(int i, int j, int *outpw)
  8. {
  9. while (--j) {
  10. if (*outpw *= i) {}
  11. }
  12. }
  13. char* ToBase3(char *res, int num, int rem, int scnt, int i, int *outscnt)
  14. {
  15. if (rem = num % 3,
  16. num /= 3,
  17. res[15-i] = "012"[rem],
  18. i += 1) {}
  19. while (i < 16)
  20. {
  21. if (rem = num % 3,
  22. num /= 3) {}
  23. if (num == 0 && rem == 0)
  24. {
  25.  
  26. if (res[15-i] = ' ',
  27. i += 1,
  28. scnt += 1) {}
  29. }
  30. else if (res[15-i] = "012"[rem],
  31. i += 1) {}
  32. }
  33. if (res[16] = 0,
  34. *outscnt = scnt) {}
  35. }
  36.  
  37. int FromBase7(char *s, int it, int *outp, int *outpw, int outsl, int acc)
  38. {
  39. if (*outp = 0) {}
  40. while (s[it] != '\0')
  41. {
  42. if (
  43. *outpw = 7,
  44. npwr(7, ((outsl-1)-it), outpw),
  45. acc += ((*outpw)*(s[it]-'0'))
  46. ) {}
  47. if (
  48. it++
  49. ) {}
  50. }
  51. if (*outp = acc) {}
  52. }
  53.  
  54. int main(int argc, char **argv, char i[20], int n1, int n2, int outpw, int outsl, char fail) {
  55. if (fail = 0,
  56. scanf("%s", i),
  57. outsl = 0,
  58. StLen(i, &outsl, 0)) {}
  59. if (outsl > 8) {if (1, printf("Input number can not be more than 8 characters"), fail = 1) {}}
  60. if (!fail)
  61. {
  62.  
  63. if (
  64. FromBase7(i, 0, &n1, &outpw, outsl, 0)
  65. ) {}
  66. if (
  67. scanf("%s", i),
  68. outsl = 0,
  69. StLen(i, &outsl, 0)
  70. ) {}
  71. if (outsl > 8) {if (1, printf("Input number can not be more than 8 characters"), fail = 1) {}}
  72. if (!fail)
  73. {
  74. if (
  75. FromBase7(i, 0, &n2, &outpw, outsl, 0),
  76. ToBase3(i, n1+n2, 0, 0, 0, &outsl),
  77. printf("%s\n", i+outsl)
  78. ) {}
  79. }
  80. }
  81. }
  82.  
  83.  
Success #stdin #stdout 4.97s 4524KB
stdin
0 64
stdout
1201