急問:有關C/C++ program

2008-10-19 6:42 am
我想問如果要人輸入一串數字,然後輸出反轉的數字同所有數字
的sum,應該點寫??

eg. input number:12345
sum of the number: 15
reverse of the no: 54321

回答 (1)

2008-10-19 11:11 am
✔ 最佳答案
I have given two answers to the same questions recently. You can refer to the links below:
http://hk.knowledge.yahoo.com/question/question?qid=7008101500730
http://hk.knowledge.yahoo.com/question/question?qid=7008101401531

#include <stdio.h>
int main(int argc, char *argv[])
{
long n;
int digit;
printf("enter a number");
scanf("%ld",&n);
while(n>0)
{
printf("%d ",n%10);
n/=10;
}
printf("\n");
}


收錄日期: 2021-04-13 16:10:30
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20081018000051KK02538

檢視 Wayback Machine 備份