时间:2011-12-25 00:27:28
第29套题
一、程序填空题
#include <stdio.h>
double fun(double e)
{ int i; double s, x;
/**********found**********/
s=0; i=__1__;
x=1.0;
while(x>e){
/**********found**********/
__2__;
/**********found**********/
x=(2.0*i-1)/((__3__)*(2.0*i));
s=s+x;
}
return s;
}
main()
{ double e=1e-3;
printf("nThe result is: %fn",fun(e));
}
二、程序改错题
#include <stdio.h>
#include <string.h>
/************found************/
void fun (char s, char t)
{
int i, d;
d = strlen(s);
for (i = 0; i<d; i++) t[i] = s[i];
for (i = 0; i<d; i++) t[d+i] = s[d-1-i];
/************found************/
t[2*d-1] = ' ';
}
main()
{
char s[100], t[100];
printf("nPlease enter string S:"); scanf("%s", s);
fun(s, t);
printf("nThe result is: %sn", t);
}
三、程序编写题
#include <stdio.h>
#include <string.h>
void fun(char *s, char t[])
{
}
main()
{
char s[100], t[100];void NONO ();
printf("nPlease enter string S:"); scanf("%s", s);
fun(s, t);
printf("nThe result is: %sn", t);
NONO();
}
void NONO ()
{/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */
char s[100], t[100] ;
FILE *rf, *wf ;
int i ;
rf = fopen("K:\k01\24010001\in.dat","r") ;
wf = fopen("K:\k01\24010001\out.dat","w") ;
for(i = 0 ; i < 10 ; i++) {
fscanf(rf, "%s", s) ;
fun(s, t) ;
fprintf(wf, "%sn", t) ;
}
fclose(rf) ;
fclose(wf) ;
}