填空题下面程序的功能是根据键盘输入的n(2≤n≤9),自动产生一个n×n的方阵a,该方阵将自然数以S形形式填充,请填空完善程序。如,n值为5,则将产生如下方阵。
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 25
#include<stdio.h>
int main()
{
int a[10][10];
int i, j, n;
printf("Input n:/n");
scanf("%d",
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
if(______)
a[i][j]=n*i+j+1;
else
a[i][j]=(i+1)*n-j;
}
}
printf("Array a is:/n");
for(i=0; i<n; i++)
{
for(j=0; j<______; j++)
printf("%4d", a[i][j]);
printf("/n");
}
return 0;
}
填空题下面程序执行后输出的结果是 【8】 。 int m=13; int fun(int x,int y) int m=3; return(x*y-m); main() int a=7,b=5; Printf(“%d/n",fun(a,b)/m);
填空题在给定程序中,函数fun的功能是:将不带头结点的单向链表逆置。即若原链表中从头至尾结点数据域依次为:2、4、6、8、10,逆置后,从头至尾结点数据域依次为:10、8、6、4、2。 请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构。 文件BLANK1.C内容如下: #include<stdio.h> #include<stdlib.h> #define N 5 typedef struct node int data; struct node *next; NODE; /**********found**********/ (1) fun(NODE *h) NODE *p,*q,*r; p=h; if(p==NULL)return NULL; q=p->next: p->next=NULL; /**********found**********/ while( (2) ) r=q->next; q->next=p; p=q; /**********found**********/ q= (3) ; return p; NODE *creatlist(int a[]) NODEh,*p,*q; int i; h=NULL; for(i=0;i<N;i++) q=(NODE%)malloc(sizeof(NODE)); q->data=a[i]; q->next=NULL; if(h==NULL)h=p=q; else p->next=q;p=q; return h; void outlist(NODE *h) NODE *p; p=h; if(p==NULL)printf("The list is NULL!/n"); else printf("/nHead"); do printf("->%d",p->data); p=p->next; while(p!=NULL); printf("->End/n"); void main( ) NODE *head; int a[N]=2,4,6,8,10; head=creatlist(a): printf("/nThe original list: /n"); outlist(head); head=fun(head); printf("/nThe list after inverting: /n"); outlist(head);
填空题实现程序可将磁盘中的一个文件复制到另一个文件中,两个文件的文件名在可执行命令的命令行中(相当于copy命令),假定文件在当前目录下。请填空。 # include<stdio.h> void main(int argc,char*argv[]) FILE*f1,*f2; if(argc______) printf("parameter error! /n"); exit(0);) f1=fopen( argv[1],"r"); f2=fopen(argv[2],"w"); while(______)fputc(fgetc(f1) ,f2); fclose(f1); fclose(f2);
填空题若输入12、3、2、5、7,则以下程序的运行结果为{{U}} {{U}} {{/U}} {{/U}}。
int max,min;
void max_min_value();
main()
{ int i,number[5];
printf("输入5个整数;/n");
for(i=0;i<5;i++) scanf("%d",&number[i]);
max min value(number,5);
printf("max=%d,min=%d/n",max,min);
getch();
}
void max_min_value(array,n)
int array[],n;
{ int*p;
max=min=*array;
for(p=array+1;p<array+n;p++)
if(*p>max)max=*p;
else if(*p<min)min=*p;
}
填空题函数pi的功能是根据以下公式近似求得的:
pi*pi/6=1+1/(2*2)+1/(3.3)+...+1/(n*n)
请在下面的函数中天空,完成求pi的功能。
#include<math.h>
double pi(long n)
{ double s=0.0,long i;
for(i=1;i<<=n;i++)s=s+{{U}} 【11】 {{/U}};
return(sqrt(6*s));
}
填空题有以下程序,程序执行后,输出结果是{{U}} {{/U}}#include<stdio.h> void fun(int*A) a[0]=a[1]; main() int a[10]=10,9,8,7,6,5,4,3,2,1,,i; for(i=2;i>1=0;i-) fun( for(i=0;i<10;i++) printf("%d,a[i]); printf("//n");
填空题以下程序运行后的输出结果是{{U}} 【12】 {{/U}}。
mam()
{
char a[]="123456789",*p;
int i=0;
p=a;
while(*p)
{
if(i%2=0)
*p='*';
p++;i++;
}
puts(A) ;
}
填空题mystrlen函数的功能是计算str所指字符串的长度,并作为函数值返回。请填空。 int mystrlen(char *str) int i; for(i=0; 【13】 !='/0';i++); return( 【14】 );
填空题下面程序执行后输出的结果是{{U}} 【10】 {{/U}}。
int m=13;
int fun(int x,int y)
{ int m=3;
return(x*y-m);
}
main()
{ int a=7,b=5;
printf("%d/n",fun(a,b)/m);
}
填空题下列给定程序中,函数fun()的功能是计算并输出high以内的素数之和。high由主函数传给fun()函数。若high的值为 100,则函数的值为1060。 请改正程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <conio.h> #include <stdio.h> #include <math.h> int fun(int high) int sum=0,n=0,j,yes; while(high>=2) yes=1; for(j=2;j<=high/2;j++) /*************found**************/ ifhigh%j==0 yes=0; break; /*************found**************/ if(yes==0) sum+=high; n++; high--; return sum; main() clrscr(); printf("%d/n",fun(100));
填空题mystrlen函数的功能是计算str所指字符串的长度,并作为函数值返回。请填空。 int mystrlen(char * str) int i; for (i=0; ______ )!='/0';i+ +) return ______);
填空题下列程序的输出结果是______。
#define P(A) printf("%d,",(int)(A) )
#definePRINT(A) P(A) ;printf("the end")
main()
{ int i,a=0;
for(i=1;i<5;++)
PRINT(a+i);
printf("/n");
}
填空题在进行模块测试时,要为每个被测试的模块另外设计两类模块:驱动模块和承接模块(桩模块)。其中 【4】 的作用是将测试数据传送给被测试的模块,并显示被测试模块所产生的结果。
填空题若用0至9之间不同的三个数构成一个三位数,下面程序将统计出共有多少种方法。请填空。 #include<stdio.h> main() int i,j,k,count=0; for(i=0;i<=9;i++) for(j=0;i<=9;j++) if(______)continue; else for(k=0;k<=9;k++) if(______)count++; printf("%d",count);
填空题请补充main 函数,该函数的功能是:先以只写方式打开文件“out99.dat”,再把字符串str中的字符保存到这个磁盘文件中。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在 main 函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include "stdio. h"
#include "conio.h"
#define N 80
main ()
{
FILE *fp;
int i=0;
char ch;
char str[N]="I'm a student!";
clrscr();
if ( (fp=fopen ({{U}} 【1】 {{/U}}) ) ==NULL)
{
printf("cannot open out99. dat/n");
exit(0);
}
while (str[i])
{
ch=str[i];
{{U}}【2】 {{/U}};
putchar(ch);
i++;
}
{{U}} 【3】 {{/U}};
}
填空题有以下程序: #include<stdio.h> main() int a[3][3]=1, 2, 3, 4, 5, 6, 7, 8, 9; int b[3]=0, i; for(i=0; i<3; i++) b[i]=a[i][2]+a[2][i]; for(i=0; i<3; i++) printf("%d", b[i]); printf("/n"); 程序运行后的输出结果是______。
填空题软件的调试方法主要有:强行排错法、______和原因排除法。
填空题下面程序由两个源程序文件:t4.h和t4.c组成,程序编译运行的结果是:【 】。
t4.h的源程序为:
#define N 10
#define f2(x) (X*N)
t4.c的源程序为:
#include
#define M 8
#define f(x) ((x)*M)
#include "t4.h"
main()
{int i,j;
i=f(1+1);j=t2(1+1);
printf("%d%d\n",i,J);
}
填空题以下程序运行后的输出结果是{{U}} 【20】 {{/U}}。
#include <stdio.h>
fun(int x)
{ if(x/2>0) fun(x/2);
printf("%d",x);
}
main()
{ fun(6); }
