第42题
功能:判断一个整数w的各位数字平方之和能否被5整除,可以被5整除则返回1,否则返回0。
#include<stdio.h>
#include<conio.h>
int fun(int w)
{
int k,s=0;
do {
_____1_____
_____2_____
}
while(_____3_____)
if(_____4_____)
_____5_____
else_____6_____
return k;
}
void main()
{
int m;
void TestFunc();
printf("Enter m: ");
scanf("%d", &m);
printf("\nThe result is %d\n", fun(m));
TestFunc();
}
void TestFunc()
{
FILE *IN,*OUT;
int c ;
int t;
int o;
IN=fopen("in.dat","r");
if(IN==NULL)
{
printf("Read File Error");
}
OUT=fopen("out.dat","w");
if(OUT==NULL)
{
printf("Write File Error");
}
for(c=1;c<=5;c++)
{
fscanf(IN,"%d",&t);
o=fun(t);
fprintf(OUT,"%d\n",o);
}
fclose(IN);
fclose(OUT);
}