Posted 2019-07-06Updated 2022-07-04Learning-Note-學習筆記a few seconds read (About 79 words)數字反轉 (Reverse Number)數字反轉 教學與筆記。 說明每執行完取 10 的餘數後,上一筆數值需要進位。以十進位來說,就是要乘以 10。 123456789101112131415161718#include <stdio.h>int reverse(int input) { int ans = 0; while (input != 0) { ans = ans * 10 + input % 10; input = input / 10; } return ans;}void main() { int input = 691; int rev = reverse(input); printf("%d\n", input); // 691 printf("%d\n", rev); // 196}數字反轉 (Reverse Number)https://meowlucian.github.io/C/Common/Reverse-Number/AuthorMeow LucianPosted on2019-07-06Updated on2022-07-04Licensed under#CodeC