Bygoewn历年全国计算机等级考试_二级C语言上机考试题库及答案
printf("\nEnter string with -1 to end :\n"); gets(str);
while(strcmp(str,"-1")!=0) { /**********found**********/
fputs(___2___,fw); fputs("\n",fw); gets(str); } }
void ReadText(FILE *fr) { char str[81];
printf("\nRead file and output to screen :\n"); fgets(str,81,fr); while( !feof(fr) ) {
/**********found**********/ printf("%s",___3___); fgets(str,81,fr); } } 修改
给定程序MODI1.c中函数fun的功能是:从低位开始取出长整形变量s中的奇数位上的数,依次构成一个新数放在t中,高位仍放在高位,低位仍放在低位。 例如:当s中的数为:7654321时,t中的数为:7531 请改正程序中的错误,使他能得出正确的结果。
注意:不要改动main函数,不能增行或删行,也不得更改程序的结构!
#include <stdio.h>
/************found************/ void fun (long s, long t) { long sl=10; *t = s % 10; while ( s > 0) { s = s/100;
*t = s%10 * sl + *t;
/************found************/ sl = sl*100; } } 程序
函数fun的功能是:将两个两位数的正整数a,b合并成一个整数放在c中。合并的方式是:将a数的十位和个位数依次放在c数的千位和十位上,b数的十位