第42题
功能:从低位开始取出长整型变量s中偶数位上的数,依次构成一个新数放在t中。
例如:当s中的数为:7654321时,t中的数为:642。
#include<stdio.h>
long fun(long s,long t)
{
long sl=10;
_____1_____
_____2_____
while(_____3_____)
{
_____4_____
_____5_____
_____6_____
}
return t;
}
void main()
{
long s, t,m;
void TestFunc();
printf("\nPlease enter s:");
scanf("%ld", &s);
m=fun(s,t);
printf("The result is: %ld\n", m);
TestFunc();
}
void TestFunc()
{
FILE *IN,*OUT;
int n;
long i,t,m;
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(n=0;n<5;n++)
{
fscanf(IN,"%ld",&i);
m=fun(i,t);
fprintf(OUT,"%ld\n",m);
}
fclose(IN);
fclose(OUT);
}