填空题以下程序是用递归方法求数组中的最大值及其下标值。请填空。 #define M 10 void findmax(int *a,int n,int i,int *pk) if(i<n) if(a[i]>a[ *pk]) 【15】 ; findmax(a,n,i+1,i++)scanf("%d" ,a+i); findmax(a,M,0,&n); printf(" The maxinum is:%d/n" ,a[n]); printf(" It's index is;%d/n" ,n);
填空题以下程序的输出结果是______。
#include<string.h>
main()
{char a[]={'/1','/2','/3','/4','/0'};
printf("% d % d/n",sizeof(a),strlen(a));
}
填空题在计算机中,字符的比较是对它们的______进行比较。
填空题以下程序运行后的输出结果是______。int f(int a[], int n) if (n >= 1) return f(a, n-1)+a[n-1]; else return 0;main() int aa[5]=1,2,3,4,5, s; s=f(aa, 5); printf("%d\n", s);
填空题下列程序中的数组a包括10个整数元素,分别将前项和后项之和存入数组b,并按每行4个元素输出数组bo请填空。 #include<stdio.h> main() int a[10],b[10],i; for(i=0;i<10;i++) scanf("%d", for(i=0;i<9;i++) ______; for(i=0;i<9;i++) if(i%4==0)printf("/n"); printf("%3d",b[i]);
填空题阅读下面程序,则程序的执行结果为 【9】 。 #include"stdio.h" main() int a=30,b=20,z; z=fun(a+b,a-b); printf("%d/n",z); fun(int a,int b) int z; z=a/b; return z;
填空题以下函数creat用来建立一个带头结点的单向链表,新产生的结点是插在链表头的末尾。单向链表的头指针作为函数值返回。请填空。 # include<stdio.h> struct list char data; struct list * next; ; struct list * creat; struct list * h,* p,* q; char ch; h=( 【18】 )malloc ( sizeof(struct list)); p=q=h; ch=getchar(); while(ch!='?') p=( 【19】)mallco(sizeof(struct list)); p->data=ch; q->next=p; q=p; ch=getchar(); p->next='/0'; 【20】;
填空题下面程序的输出结果是______。 #include<stdio.h> main() static char a[]="china"; char*ptr=a; while(*ptr) printf("%c",*ptr-32); ptr++;
填空题以下程序运行后的输出结果是______。 main () int x=10,y=20, t=0 if(x==y) t=x;x=y;y=t; printf("%d,%d /n",x,y);
填空题在一个容量为15的循环队列中,若头指针front=6,尾指针Year=9,则该循环队列中共有 【1】 个元素。
填空题设i,j,k均是int型变量,则执行以下for循环后,k的值为 【9】 。 for(i=0,j=10;i<=j;i++,j--) k=i+j;
填空题以下程序中给指针p分配三个double型动态内存单元,请填空。
# include <stdlib.h>
main ( )
{ double *p;
p=(double *) malloc( {{U}} 【18】 {{/U}} );
p[0]=1.5;p[1]=2.5;p[2]=3.5;
printf(“%f%f%f/n”,p[0],p[1],p[2]);
}
填空题若有如下程序: main() int x=4,y=3,x=2,t; t=x<y<z; printf("%d/n",t); 则程序运行后的输出结果是 【6】 。
填空题以下程序的输出结果为______。 #define JFT(x) x*x main( ) int a,k=3; a=++JFT(k+1); printf("%d",a);
填空题以下函数sstrcat()的功能是实现字符串的连接,即将t所指字符串复制到s所指字符串的尾部。例如:s所指字符串为abed,t所指字符串为efgh,函数调用后s所指字符串为abodefgh。请填空。 #include <string.h> void sstrcat(char *s,char *t) int n; n=strlen(s); while(*(s+n)= 【13】 )s++;t++;
填空题给定程序中已建立一个带有头结点的单向链表,在main()函数中将多次调用fun()函数,依次输出链表尾部结点中的数据,并释放该结点,使链表缩短。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 #include<stdio.h> #include<stdlib.h> #define N 8 typedef struct list int data; struct list *next; SLIST; void fun(SLIST *p) SLIST *t,*s; t=p->next;s=p; while(t->next!=NULL) s=t; /**********found**********/ t=t-> (1) ; /**********found**********/ printf("%d", (2) ); s->next=NULL; /**********found**********/ free( (3) ); SLIST *creatlist(int *a) SLIST*h,*p,*q;int i; h=p=(SLIST*)malloc(sizeof(SLIST)); for(i=0;i<N;i++) q=(SLIST*)malloc(sizeof(SLIST)); q->data=a[i];p->next=q;p=q; p->next=0; return h; void outlist(SLIST *h) SLIST *p; p=h->next; if(p==NULL)printf("/nThe list is NULL!/a"); else printf("/nHead"); do printf("->%d",p->data);p=p->next;while(p!=NULL); printf("->End/n"); main() SLIST *head; int a[N]=11,12,15,18,19,22,25,29; head=creatlist(a); printf("/nOutput from head:/n");outlist(head); printf("/nOutput from tail:/n"); while(head->next!=NULL) fun(head); printf("/11/n"); printf("/nOutput from head again:/n");outlist(head);
填空题分析下列程序: main() int x=1,y=0,a=0,b=0; switch(a) case 1:switch(b) case 0:x++; case 1:y++;break; case 2:x++;y++;break; printf("x=%d,y=%d/n",x,y); 运行程序的输出结果是______。
填空题请补充函数fun(),该函数的功能是:把字符串str中的字符按字符的ASCⅡ码降序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传入。
例如,如果输入“cdefgh”,则输出为“hgfedc”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#define N 80
void fun (char s [], int n)
{
int i, j;
char ch;
for (i=0; i<n; i++)
for(j={{U}} 【1】 {{/U}};j<n;j++)
if (s[i]<s [j])
{
ch=s [j];
{{U}} 【2】 {{/U}};
s [i] =ch;
}
main ( )
{
int i=0, strlen=0;
char str [N];
clrscr ();
printf ("/nInput a string: /n");
gets (str);
while (str [i] !=' /0')
{
strlen++;
i++;
}
fun (str, strlen);
printf ("/n***display string ***/n");
puts (str);
}
填空题以下程序运行后的输出结果是______。 #include<stdio.h> main() int a=1, b=2, e=3, d=0; if(a==1) if(b!=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);
填空题以下程序运行后输入:3,abcde,则输出结果是【 】
#include <string.h>
move(char *str, int n)
{ char temp; int i;
temp=str[n-1];
for(i=n-1;i>0;i--) str[i]=str[i-1];
str[0]=temp;
}
main( )
{ char s[50]; int n, i, z;
scanf("%d,%s",
z=strlen(s);
for(i=1; i<=n; i++= move(s, z);
printf("%s/n",s);
=
