功能:从低位开始取出长整型变量s中偶数位上的数,依次构

功能:从低位开始取出长整型变量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);
}
答案
第1空:s /= 10;
第2空:t = s % 10;
第3空:s > 0
第4空:s = s/100;
第5空:t = s%10*sl + t;
第6空:sl = sl * 10;

题目信息

题号:6774
题型:填空题
难度:普通