填空题下面程序的运行结果是 【20】 。 main() int y,a; y=2,a=1; while(y--!=-1) doa*=y;a++;while(y--); printf("%d,%d",a,y);
填空题有以下程序:
# include<stdio.h>
main()
{ int a[]={1,2,3,4,5,6,7,8,9,10,11,12}, *p=a+5, *q=NULL;
*q=*(p+5);
printf("%d%d/n",*p,*q);
}
程序运行后的输出结果是{{U}} 【10】 {{/U}}。
填空题以下程序运行后的输出结果是______。 #include<stdio.h> typedef struct int num; double s; REC; void fun1(REC x)x.num=23; x.s=88.5; main() REC a=16, 90.0; fun1(a); printf("%d/n", a.num);
填空题请补充main函数,该函数的功能是:从键盘输入一个长整数,如果这个数是负数,则取它的绝对值,并显示出来。
例如,输入:-3847652,结果为:3847652。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
main()
{
long int n;
clrscr();
printf("Enter the data;/n");
scanf({{U}} {{U}} {{/U}} {{/U}});
printf("*** the absolute value ***/n");
if(n<0)
{{U}} {{U}} {{/U}} {{/U}}
printf("/n/n");
printf({{U}} {{U}} {{/U}} {{/U}});
}
填空题以下程序运行时从键盘输入:1.0 2.0 ,输出结果是:1.000000 2.000000,请填空
#include
main()
{ double a; float b;
scanf("U [7] /U ",
printf("%f %f\n", a, b);
}
填空题函数fun的功能是:根据以下公式求p的值,结果由函数值返回。m与n为两个正数且要求m>n。例如:m=12,n=8时,运行结果应该是495.000000。请在题目的空白处填写适当的程序语句,将该程序补充完整。#include<conio.h>#include<stdio.h)floatfun(intm,intn)inti;doublep=1.0;for(i=1;i<=m;i++)【15】;for(i=1;i<=n;i++)【16】;for(i=1;i<=m-n;i++)p=p/i;returnP;main()clrscr();printf("p=%f/n",fun(12,8));
填空题以下程序运行后的输出结果是{{U}} 【14】 {{/U}}。
#include<string.h>
void fun(char *s,int P,int k)
{int i;
for(i=p;i<k-1;i++)s[i]=s[i+2];
main()
{char s[]="abcdefg";
fun(s,3,strlen(s));puts(s)
}
填空题下列给定程序中,函数fun()的功能是:根据以下公式求n的值,并作为函数值返回。例如,给指定精度的变量eps输入 0.0005时,应当输出Pi=3.140578。
n/2=1+1/3+1/3*2/5+1/3*2/5*3/7+1/3*2/5*3/7*4/9……
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <conio.h>
#include <stdio.h>
#include <math.h>
double fun(double eps)
{double s,t; int n=t;
s=0.0;
/*************found**************/
t=1;
/*************found**************/
while(t>eps)
{ s+=t;
t=t*n/(2*n+1);
n++;
}
/*************found**************/
return (s);
}
main()
{ double x;
printf("/nPlease enter a precision: ");
scanf("%1f",
printf("/nPi=%1f/n ",fun(x));
}
填空题下列程序的输出结果是______。 # include<string.h> main() char b[30],*chp; strcpy(&b[0],"CH"); strcpy(&b[1],"DEF"); strcpy(&b[2],"ABC"); printf("%s/n",b);
填空题函数delete(s,i,n)是作用是从字符串s中删除从第i个字符开始的n个字符,请填空。 void delete(char s[], int i,int n) int j,k,length=0; while(s[length]) 【16】 ; -i; j=i; if( 【17】 ) k=i+n; if(i+n<=length) while(k<length) s[j++]=s[k++]; s[j]/'/0';
填空题下列程序的输出结果是______。 #include<stdio.h> int t(int x,int y,int cp,int dp) cp=x*x+y*y; dp=x*x-y*y; main() int a=1,b=8,c=7,d=9; t(a,b,c,d); printf("%d %d/n",c,d);
填空题以下程序运行后的输出结果是【 】。
main()
{int a=1,b=2,c=3;
if(c=a) ,printf("%d\n",c) ;
else printf("%d\n",b) ;
}
填空题下列给定程序中函数fun()的功能是:计算n!。例如,给 n输入5,则输出120.000000。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include <stdio.h>
#include <conio.h>
double fun (int n)
{ double result=l.0;
/*************found**************/
if n==0
return 1.0;
while (n>l
}
main ( )
{ int n;
printf ("Input N: ");
scanf ( "%d"
printf ("/n/n%d!=%lf/n/n",n, fun(n));
}
填空题请补充函数fun(),该函数的功能是:按‘0’到‘9’统计一个字符串中的奇数数字字符各自出现的次数,结果保存在数组num中。注意:不能使用字符串库函数。 例如:输入“x=112385713.456+0.909*bc”,结果为:1 =3,3=2,5=2,7=1,9=2。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #define N 1000 void fun(char*tt,int num[]) int i,j; int bb[10]; char *p=tt; for(i=0;i<10;i++) num[i]=0; bb[i]=0; while ( 【1】 ) if(*p>=‘0’ main() char str[N]; int num[10],k; clrscr(); printf("/nPlease enter a char string:"); gets(str); printf("/n**The original string**/n"); puts(str); fun(str,num); printf("/n**The number of letter**/n"); for(k=0;k<5;k++) printf("/n"); printf("%d=%d",2*k+1,num[k]); printf("/n"); return;
填空题以下程序运行后的输出结果是______。
main()
{ char a[]="123456789",*p;
int i=0;
p=a;
while (*p)
{ if(i%2==0) *p='*';
p++;
i++;
}
puts(a);
}
填空题若有以下程序段: int c1=1,c2=2,c3; c3=1.0/c2*c1; 则执行后,c3中的值是______。
填空题在给定程序中,函数fun的功能是:将a和b所指的两个字符串转换成面值相同的整数,并进行相加作为函数值返回,规定字符串中只含9个以下的数字字符。 例如:主函数中输入字符串:32486和12345,在主函数中输出的函数值为:44831。 请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。 文件BLANK1.C内容如下: #include<stdio.h> #include<string.h> #include<ctype.h> #define N 9 long ctod(char *s) long d=0; while(*s) if(isdigit(*s)) /**********found**********/ d=d*10+*s- (1) ; /**********found**********/ (2) ; return d; long fun(char *a,char *b) /**********found**********/ return (3) ; void main( ) char s1[N],s2[N]; do printf("Input string s1: "); gets(s1); while(strlen(s1)>N); do printf("Input string s2: "); gets(s2); while(strlen(s2)>N); printf("The result is: %1d/n",fun(s1,s2));
填空题下列给定程序中,函数fun()的功能是:根据整型形参n,计算如下公式的值。A1=1,A2=1/(1+A1),A3=1/(1+A2),…,An=(1/(1+A(n-1)) 例如,若p=10,则应输出0.617977。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动mah函数,不得增行或删行,也不得更改程序的蛄构. 试题程序: #include <conio.h> #include <stdio.h> /**************found********************/ iht fun(iht n) { float A=l;inti; /**************foudn********************/ for(i=2;i<n;i++) A=1.0/(i+A); return A; } main () { int n; clrscr (); printf("/nPlease enter n: "); $canf ("%d", printf ("A%d=%lf/n", n, fun (n)); }
填空题以下程序的输出结果是______。 # include <stdio.h> main() int n=12345, d; while(n!=O) d=n%10; printf("%d",d); n/=10;
填空题请补充main 函数,该函数的功能是:计算两个自然数n和m(m<10000)之间所有数的和(n和m从键盘输入)。
例如:当n=1,m=100时,sum=5050:当n=100,m=1000时,sum=495550。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在 main 函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#include<conio.h>
main ()
{
int n, m;
long sum;
{{U}} 【1】 {{/U}}
clrscr ();
printf ("/nInput n,m/n");
scanf ("%d, %d",
while (n<=m)
{
{{U}}【2】 {{/U}}
n++;
}
printf ("sum=%{{U}} 【3】 {{/U}}/n", sum);
}
