2010計(jì)算機(jī)等考二級(jí)C:50套上機(jī)程序填空題(4)

字號(hào):

2010計(jì)算機(jī)等考二級(jí)C:50套上機(jī)程序填空題(4)

    7、給定程序中,函數(shù)fun的功能是:將形參n中,各位上為偶數(shù)的數(shù)取出,并按原來(lái)從高位到低位的順序組成一個(gè)新的數(shù),并作為函數(shù)值返回。
    例如,從主函數(shù)輸入一個(gè)整數(shù):27638496,函數(shù)返回值為:26846。
    請(qǐng)?jiān)诔绦虻南聞澗€處填入正確的內(nèi)容并把下劃線刪除, 使程序得出正確的結(jié)果。
    注意:源程序存放在考生文件夾下的BLANK1.C中。
    不得增行或刪行,也不得更改程序的結(jié)構(gòu)!
    #include
    unsigned long fun(unsigned long n)
    { unsigned long x=0, s, i; int t;
    s=n;
    /**********found**********/
    i=__1__;
    /**********found**********/
    while(__2__)
    { t=s%10;
    if(t%2==0){
    /**********found**********/
    x=x+t*i; i=__3__;
    }
    s=s/10;
    }
    return x;
    }
    main()
    { unsigned long n=-1;
    while(n>99999999||n<0)
    { printf("Please input(0
    printf("\nThe result is: %ld\n",fun(n));
    }
    8、給定程序中,函數(shù)fun的功能是:將a所指3×5矩陣中第k列的元素左移到第0列,第k列以后的每列元素行依次左移,原來(lái)左邊的各列依次繞到右邊。
    例如,有下列矩陣:
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    若k為2,程序執(zhí)行結(jié)果為
    3 4 5 1 2
    3 4 5 1 2
    3 4 5 1 2
    請(qǐng)?jiān)诔绦虻南聞澗€處填入正確的內(nèi)容并把下劃線刪除,使程序得出正確的結(jié)果。
    注意:源程序存放在考生文件夾下的BLANK1.C中。
    不得增行或刪行,也不得更改程序的結(jié)構(gòu)!
    #include
    #define M 3
    #define N 5
    void fun(int (*a)[N],int k)
    { int i,j,p,temp;
    /**********found**********/
    for(p=1; p<= __1__; p++)
    for(i=0; i
    { temp=a[i][0];
    /**********found**********/
    for(j=0; j< __2__ ; j++) a[i][j]=a[i][j+1];
    /**********found**********/
    a[i][N-1]= __3__;
    }
    }
    main( )
    { int x[M][N]={ {1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5} },i,j;
    printf("The array before moving:\n\n");
    for(i=0; i
    { for(j=0; j
    printf("\n");
    }
    fun(x,2);
    printf("The array after moving:\n\n");
    for(i=0; i
    { for(j=0; j
    printf("\n");
    }
    }