填空题如下图所示的二叉树后序遍历序列是{{U}}【1】{{/U}}。
填空题算法的复杂度主要包括______复杂度和空间复杂度。
填空题下列程序的运行结果是 【16】 。 #include <string.h> char *ss(char *s) return s+strlen(s)/2; main() char *p,*str="abcdefgh"; p=ss(str); printf("%/n",p);
填空题下面程序的运行结果是______。
#include<stdio.h>
#define SIZE 12
main()
{ char s[SIZE];int i; for(i=0;i<SIZE;i++) s[i]]='A'+i+321;
sub(s,7,SLZE-1);
for(i=0;i<SIZE;i++) printf("%c",s[i]);
printf("/n");}
sub(char*a,int tl,int t2)
{char Ch;
while (t1<t2)
{ ch=*(a+t1);
*(a+t1)=*(a+t2);
*(a+t2)=ch;
t1++;t2--;}}
填空题请补充main()函数,该函数的功能是:输入两个正整数num1和num2,求这两个数的最大公约数和最小公倍数。
例如,若输入的两个正整数为12,4,则它们的最大公约数为4,最小公倍数为12。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在main()函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
void main()
int a,b,num1,num2,t;
system("CLS");
printf("/nInput two numbers:/n");
scanf("%d,%d",
if(num1<num2)
{
a=num2;
b=num1;
}
else
{
a=num1;
b=num2;
}
while(______)
{
t=______
a=b;
b=t;
}
printf("greatest common divisor:%d/n",a);
printf("least common multiple:%d/n",______);
}
填空题下面程序的功能是将一个字符串sfr的内容颠倒过来,请填空。 #include<string.h> main() int i,j, (13) ;char str[]="1234567"; for(i=0,j=strlen(str) (14) ;i<j;i++,j--) k=str[i];str[i]=str[j];str[j]=k; printf("%s/n",str);
填空题以下程序中,fun函数的功能是求3行4列二维数组每行元素中的最大值。请填空。 void fun(int,int,int(*)[4],int*); main() int a[3][4]=12,41,36,28,19,33,15,27,3,27,19,1,b[3],i; fun(3,4,a,b); for(i=0;i<3;i++)printf("%4d",b[i]); printf("/n"); void fun(int m,int n,int ar[][4],int *br) int i,j,x; for(i=0;i<m;i++) x=ar[i][0]; for(j=0;j<n;j++)if(x<ar[i][j])x=ar[i][j]; ______=x;
填空题以下程序的运行结果是 【8】 。 #include <stdio.h> long fib (int g) switch (g) case 0: return 0; case 1: case2: return 1; return (fib(g-1)+fib(g-2)); main() long k; k=fib(5); printf("k=%d/n",k);
填空题以下程序中,函数fun的功能是计算x2-2x+6,主函数中将调用fun函数计算: y1=(x+8)2-2(x+8)+6 y2=sin2(x)-2sin(x)+6 请填空。 double fun(double x)return(x*x-2*x+6); double x,y1,y2; printf("Enter x:");scanf("%lf",&x); y1=fun( [6] ); y2=fun( [7] ); printf("y1=%lf,y2=%lf/n",y1,y2);
填空题—个关系表的行称为{{U}} [3] {{/U}}。
填空题以下程序的功能是输入任意整数给n后,输出n行从大写字母A开始构成的三角形字符阵列图形。例如,输入整数5时(注意:n不得大于10),程序运行结果如下: A B C D E F C H I J K L M N O 请填空完成该程序。 #include <stdio.h> main( ) int i.j,n;char ch ='A'; scanf(" % d" , if( n<11 ) for(i=1; i<=n;i++) for(j =1; j< =n-i+1;j++) printf( "%2c" ,ch); ______; ______; else printf ("n is too large! /n" ); prinff("/n");
填空题以下程序运行后的输出结果是______。 #include<stdio.h> int a=5; void fun(int b) int a=10; a+=b; printf("%d", a); main() int c=20; fun(c); a+=c; printf("%d/n", a);
填空题在Windows环境下,为了进行"添加/删除程序"操作,首先打开{{U}} 【5】 {{/U}},然后双击其中的相应图标。
填空题以下程序的输出结果是______。 #inciude<stdio.h> main() char s[]="ABCabc"; s[5]='/0'; printf("%s/n",s);
填空题请补充函数fun(),该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字符串所包含的指定字符的个数是奇数,则不予删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,a指向原字符串,删除后的字符串存放在b所指的数组中,c中存放指定的字符。 例如:当a输入“abababa”,c=‘a’时,b的输出为“ababb”; 如果a的输入为“ababa”,则b的输出为“ababa”。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #include<conio.h> #define LEN 80 void fun(char a[],char b[],char C) int i=0,j=0; int n=0; int m=0; while(a[i]!=‘/0’) if(a[i]==c) n++; i++; 【1】 ; if(n%2) while(a[j]!='/0') b[j]=a[j]; j++; b[j]='/0'; else while(a[i]!='/0') b[j++]=a[i]; if(a[i]==c) m++; if((m>n/2)&&(a[i]==c)) 【2】 ; i++; 【3】 ; main() char a[LEN],b[LEN]; char c; clrscr(); printf("Enter the string:/n"); gets(a); printf("Enter the character of the string deleted:"); scanf("%c",&c); fun(a,b,c); printf("The new string is:%s/n",b);
填空题下列给定程序中,函数fun()的功能是:将长整型数中各位上为奇数的数依次取出,构成一个新数放在t中。高位仍在高位,低位仍在低位。
例如,当s中的数为87653142时,t中的数为7531。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void fun(long s,long*t)
{
int d;
long s1=1;
//****found****
t=0;
while(s>0)
{
d=s%10;
//****found****
if(d%2==0)
{
*t=d*s1+*t;
s1*=10;
}
s/=10;
}
}
void main()
{
long s,t;
system("CLS");
printf("/nPlease enter s:");
scanf("%id",
fun(s,
printf("The result is:%id/n",t);
}
填空题下列程序的输出结果是______。 #include<stdio.h> int fun(int x) static int t=0; return(t+=x); main() int s,i; for(i=1;i<=5;i++)s=fun(i); printf("%d/n",s);
填空题有以下程序
main( )
{ int n=0,m=1,x=2;
if(!n) x-=1;
if(m) x-=2;
if(x) x-=3;
printf(“%d/n”,x);}
执行后输出结果是 {{U}} 【9】 {{/U}}。
填空题以下程序用来统计文件中字符的个数。请填空。 #include“stadio.h” main() FILE *fp;long num=0L; if((fp=fopen(“fname.dat”,“r”))==NULL); printf(“0pen error/n”);exit(0); while( 【16】 ) fsetc(fp);num++; printf(“num=%1d/n”,num-1); fclose(fp);
填空题下面程序的功能是建立一个有3个结点的单循环链表,然后求各个结点数值域data中数据的和,请填空。#include<stdio.h>#include<stdlib.h>structNODE{intdata;structNODE*next;};main(){structNODE*p,*q,*r;intsum=0;p=(structNODE*)malloc(sizeof(structNODE));q=structNODE*)malloc(sizeof(structNODE));r=(structNODE*)malloc(sizeof(structNODE));p->data=100;q->data=200;r->data=300;p->next=q;q->next=r;r->next=p;sum=p->data+p->next->data+r->next->next{{U}}【19】{{/U}};printf("%d/n",sum);}
