---
# System prepended metadata

title: 12394 - Easy Palindrome
tags: [array]

---

# 12394 - Easy Palindrome
>author: Utin
###### tags: `array`

---

## Brief
倒著input進位比較好處理，或著可以設一個變數紀錄有無千位數
*若陣列不是全域變數請記得初始化

## Solution 0

```c=
#include <stdio.h>

int n[7];

int main() {

    // input
    for (int i = 5; i >= 0; i--) {
        n[i] = getchar() - '0';
        if (i == 3) getchar();
    }

    // add
    for (int i = 0; i < 6; i += 3) {
        n[i] = n[i+2] = n[i] + n[i+2];
        n[i+1] *= 2;
    }

    // carry
    for (int i = 0; i < 6; i++) {
        n[i+1] += n[i] / 10;
        n[i] %= 10;
    }

    // output
    if (n[6]) printf("%d", n[6]);
    for (int i = 5; i >= 0; i--) {
        printf("%d", n[i]);
        if (i == 3) printf(".");
    }
}
// By Utin
```

## Reference