#include "stdio.h"
int fun(int W)
{
int sum=0;
while(W)
sum+=(W%10)*(W%10);
W/=10;
}
if(sum%5==0)return 1;
return 0;
void main()
int W;
scanf("%d",&W);
printf("%d",fun(W));
擴充套件資料
C語言實斷迴文數
#include<stdio.h>
intmain()
intn,reversedInteger=0,remainder,originalInteger;
printf("輸入一個整數:");
scanf("%d",&n);
originalInteger=n;
//翻轉
while(n!=0)
remainder=n%10;
reversedInteger=reversedInteger*10+remainder;
n/=10;
//判斷
if(originalInteger==reversedInteger)
printf("%d是迴文數。",originalInteger);
else
printf("%d不是迴文數。",originalInteger);
return0;
#include "stdio.h"
int fun(int W)
{
int sum=0;
while(W)
{
sum+=(W%10)*(W%10);
W/=10;
}
if(sum%5==0)return 1;
return 0;
}
void main()
{
int W;
scanf("%d",&W);
printf("%d",fun(W));
}
擴充套件資料
C語言實斷迴文數
#include<stdio.h>
intmain()
{
intn,reversedInteger=0,remainder,originalInteger;
printf("輸入一個整數:");
scanf("%d",&n);
originalInteger=n;
//翻轉
while(n!=0)
{
remainder=n%10;
reversedInteger=reversedInteger*10+remainder;
n/=10;
}
//判斷
if(originalInteger==reversedInteger)
printf("%d是迴文數。",originalInteger);
else
printf("%d不是迴文數。",originalInteger);
return0;
}