填空题软件生命周期包括8个阶段。为使各时期的任务更明确,又可以分为以下3个时期:软件定义期、软件开发期、软件维护期。编码和测试属于______期。
填空题下面程序的运行结果是______。 #include <stdio.h> main() int y,a; y=2,a=1; while(y--!=-1) doa*=y;a++; while(y--); printf("%d,%d",a,y);
填空题str是全部由小写字母字符和空格字符组成的字符串,由num传入字符串的长度。请补充函数proc(),该函数的功能是:统计字符串str中的单词个数,结果由变量num传回。每个单词之间都由空格隔开,并且字符串str开始不存在空格。
例如,str="how do you do",结果为num=4。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define M 80
void proc(char*str,int*num)
{
int i,n=0;
for(i=0;______;i++)
{
if(str[i]>="a"
}
______;
}
void main()
{
char str[M];
int num=0;
printf("Enter a string:/n");
gets(str);
while(str[num])
num++;
proc(str,
printf("The number of word is:
%d/n/n",num);
}
填空题下列程序的运行结果是______。 #include<stdio.h> func(a,b) static int m=0,i=2; i+=m+1; m=i+a+b; return(m); main() int k=5,m=3,p; p=fune(k,m); printf("%d",p); p=func(k,m); printf("%d/n",p);
填空题有以下程序: #include<stdio.h> main() int a=1,b=2,c=3,d=0; if(a==1) if(b1=2) if(c==3) d=1; else d=2; else if(c!=3) d=3; else d=4; else d=5; printf("%d/n",d); 程序运行后的输出结果是______。
填空题以下程序的输出结果是 【10】 。 main() int a=1,b=2; a=a+b;b=a-b;a=a-b; printf("%d,%d/n",a,b);
填空题以下程序的输出结果是{{U}} {{U}} {{/U}} {{/U}}。
#include <stdio.h>
main()
{ int i;
for(i='a';i<'f';i++,i++)printf("%c",i-'a'+'A');
printf("/n");
}
填空题下面函数用来求两个单精度数之和,并通过形参将结果传回,请填空。 void sub(float x,float y, 【18】 z) 【19】 =x+y;
填空题已有定义;char c=' ';int a=1,b;(此处c的初值为空格字符),执行b=!c &&a;后b的值为{{U}} 【6】 {{/U}}。
填空题以下函数把b字符串连到a字符串的后面,并返回a中新字符串的长度,请填空。
strcen(char a[],char b[])
{
int num=0,n=0;
while(*(a+num)!={{U}} {{U}} {{/U}} {{/U}})num++;
while(b[n]){*(a+num)=b[n];num++;{{U}} {{U}} {{/U}} {{/U}};}
return num;
}
填空题用以下语句调用库函数malloc,使字符指针st指向具有11个字节的动态存储空间,请填空。 st=(char *) 【8】 ;
填空题设有以下结构体类型: struct st charname[8]; int num; float s[4]; student[50];并且结构体数组student中的元素都已有值。若要将这些元素写到硬盘文件fp中,请将以下 fwrite语句补充完整: fwrite(student, 【20】 ,1,fp);
填空题给定程序MODI1.C中fun函数的功能是求出以下分数序列的前n项之和。和值通过函数值返回main函数。例如,若n=5,则应输出:8.391667。请改正程序中的错误,使它能计算出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!给定源程序如下。#include<stdio.h>/******found*******/fun(intn){inta=2,b=1,c,k;doubles=0.0;for(k=1;k<=n;k++){s=s+1.0*a/b;/********found*******/c=a;a+=b;b+=c;}return(s);}main(){intn=5;printf("/nThevalueoffunctionis:%lf/n",fun(n));}
填空题下列给定的程序中,函数proc()的功能是:为一个偶数寻找两个素数,这两个素数之和等于该偶数,并将这两个素数通过形参指针传回主函数。
请修改函数proc()中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include<stdio.h>
#include<math.h>
void proc(int num,int*b,int*c)
{
int i,j,d,y;
for(i=3;i<=num/2;i=i+2)
//****found****
{ y=0;
for(j=2;j<=sqrt((double)i);j++)
if(i%j==0)y=0;
if(y==1)
//****found****
{ d=i-num;
for(j=2;j<=sqrt((double)d);
j++)
if(d%j==0)y=0;
if(y==1)
{ *b=i;*c=d;}
}
}
}
void main()
{ int num,b,c;
do
{ printf("/nInput num:");
scanf("%d",}
while(num%2);
proc(num,
printf("/n/n%d=%d+%d/n",num,b,c);
}
}
填空题以下程序中,函数 sumColumM的功能是:求出M行N列二维数组每列元素中的最小值,并计算它们的和值。和值通过形参传回主函数输出。请填空。
#define M 2
#define N 4
void SumColumMin(int a[M][N],int *sum)
{ int i,j,k,s=0;
for(i=0;i〈N;i++)
{ k=0;
for(j=1;j<M;j++)
if(a[k][i]>a[j][i])k=j;
s+= {{U}} 【18】 {{/U}};
}
{{U}} 【19】 {{/U}} =s;
}
main( )
{ int x[M][N]={3,2,5,1,4,1,8,3},s;
SumColumMin( {{U}} 【20】 {{/U}} );
printf("%d/n",s);
}
填空题下列程序的运行结果是______。 #define POWER(x)((x)*(x)) main() int i=1; primtf("%d,%d",POWER(i++),i);
填空题若有定义语句:int a=5;,则表达式a++的值是______。
填空题以下程序的输出结果是______。 #include <stdio.h> main() int a[5]=2,4,6,8,10,*p; p=a;p++; prinft("%d",*p);
填空题以下程序的功能是:将输入的正整数按逆序输出。例如:若输入135则输出531。请填空。
#include
main()
{ int n,s;
prinff("Enter a number:");scanf("%d",&n);
printf("output: ");
do
{ S=n%10;printf("%d",s).【 】;}
while(n!=O);
printf("\n");
}
填空题以下程序的运行结果为 【7】 。#define N 5main() int a[N]=1,2,3,4,5,i,temp; for (i=0;i<N/2;i++) temp=a[i]; a[i]=a[N-i-1]; a[N-i-1)=temp; printf("/n"); for (i=0;i<n;i++) printf("%d",a[i]);
