在c语言中,我们该怎么来判断一个数是否为回文数呢?
回文数如1 22 303 18081,那么下面进入c代码的书写
操作方法
(01)新建打开vc6.0的编译系统,新建一个新的文件,命名 .c
(02)写入程序代码#include "stdio.h"#include "conio.h"main(){ long a,n=0,temp;printf("please input a integer numbern");scanf("%ld",&a);temp=a;while(a!=0) { n+=a%10; a/=10; n*=10; } printf("%ldn",n/10);if(temp==n/10) printf("it is turn number");else printf("it is not turn number") ; getch();}
(03)点击组建下的组建 编译 执行
(04)执行后的结果,此程序优点,不用对数字的位数不做要求,不管几位都可以判断,只要是4bit内的整数。
特别提示
注意c语言的语法特点