判断是否为回文数与斐波拉契序列问题

判断是否为回文数

# include intmain(void) { int val; int m; int sum = 0; printf("请输入要判断的数字:\n"); scanf("%d",&val); m = val; while(m) { sum = sum * 10+ m%10; m /= 10; } if(sum == val) printf("yes!\n"); else printf("no!\n"); return 0; }


斐波拉契序列:1,2,3,5,8,13,19,……
【判断是否为回文数与斐波拉契序列问题】
# include int main(void) { int n; int f1,f2,f3; int i; f1 = 1; f2 = 2; printf("请输入您要计算的序列:"); scanf("%d",&n); if(1 == n) { f3 = 1; } else if(2 == n) { f3 = 2; } else for(i=3; i<=n; ++i) { f3 = f1 + f2; f1 = f2; f2 = f3; } printf("%d\n",f3); return 0; }



    推荐阅读