填空题下面程序的功能是将字符串a下标值为偶数的元素由小到大排序,其他元素不变,请填空。 #include<stdio.h> main() char a[]="labchmfye",t: int 1,j; for(i=0; i<7; i+=2) for(j=i+2; j<9;______) if(______) t=a[i]; a[i]=a[j]; a[j]=t; j++; puts(a) ;printf("/n");
填空题给定程序中,函数fun的功能是将不带头结点的单向链表逆置,即若原链表中从头至尾结点数据域依次为2、4、6、8、10,逆置后,从头至尾结点数据域依次为10、8、6、4、2。
请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<stdlib.h>
#define N 5
typedef struct node{
int data;
struct node*next;
}NODE;
/*********found*********/
______*fun(NODE*h)
{NODE*p,*q,*r;
p=h;
if(p==NULL)
return NULL;
q=p->next;
p->next=NULL;
while(q)
{
/*********found*********/
r=q->______;
q->next=p;
p=q;
/*********found*********/
q=______;
}
return p;
}
NODE*creatlist(int a[])
{NODE*h,*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");
}
}
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);
}
填空题已知字母A的ASCII码为65。以下程序运行后的输出结果是______。 main() char a,b; a='A'+'5'-'3';b=a+'6'-'2'; printf(¨%d%c/n¨,a.b);
填空题语句"int(*ptr)();"的含义是______是指向函数的指针,该函数返回一个int型数据。
填空题以下程序的输出结果是 【20】 。#define MAX(x,y) (x)>(y)?(x):(y)main() int a=5,b=2,c=3,d=3,t; t=MAX(a+b,c+D) *10; printf("%d/n",t);
填空题以下程序的运行结果是______。
main()
{ char a=-10;
unsigned char b=10;
printf("%d,%d",a>>2,b>>2);
}
填空题以下程序的输出结果是{{U}} 【20】 {{/U}}。
#define MAX(x,y) (x)>(y)?(x):(y)
main()
{ int a=5,b=2,c=3,d=3,t;
t=MAX(a+b,e+d)*10;
printf("%d/n",t);
}
填空题str是一个由数字和字母字符组成的字符串,由变量num传入字符串长度。请补充函数fun(),该函数的功能是:把字符串str中的数字字符转换成数字并存放到整型数组bb中,函数返回数组bb的长度。 例如:str=“Bcdl23e456hui890”,结果为:123456890。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。 试题程序: #include<stdio.h> #define N 80 int bb[N]; int fun(char s[ ],int bb[ ],int num) int i,n=0; for(i=0;i<num;i++) if( 【1】 ) bb[n]= 【2】 ; n++; return 【3】 ; main() char str[N]; int num=0,n,i; printf("Enter a string:/n"); gets(str); while(str[num]) num++; n=fun(str,bb,num); printf("/nbb="); for(i=0;i<n;i++) printf("%d",bb[i]);
填空题函数mystrlen(char *s)的功能是求字符串s的长度,请填空。 mystrlen(char *s) char *t: t=s; while( 【8】 )t++; return(t-s);
填空题给定程序MODI1.C中函数fun的功能是在p 所指字符串中找出ASCII码值最大的字符
填空题在面向对象的程序设计中,类描述的是具有相似性质的一组 【2】 。
填空题数据流的类型有 【3】 和事务型。
填空题下列程序输出的结果是______.
int m=17;
int fun(int x,int y)
{ int m=3;
return(x*y-m);
}
main()
{ int a=5,b=7;
printf("%d/n",fun(a,b)/m);
}
填空题设在主函数中有以下定义和函数调用语句,且fun函数为void类型;请写出fun函数的首部{{U}} 【15】 {{/U}}。要求形参名为b。
main()
{ double s[10][22];
int n;
……
fun(s);
……
}
填空题若运行时给变量x输入12,则以下程序的运行结果是 【8】 ; main() int x,y; scanf(""%d"",&x); y=x>12?x+10:x-12; printf(""%d/n"",y);
填空题给定程序中,函数fun的功能是:将参数给定的字符串、整数、浮点数写到文本文件中,再用字符串方式从此文本文件中逐个读入,并调用库函数atoi和atof将字符串转换成相应的整数、浮点数,然后将其显示在屏幕上。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<stdlib.h>
void fun(char *s, int a, double f)
{
/**********found**********/
______ fp;
char str[100], str1[100], str2[100];
int a1; double f1;
fp=fopen("file1.txt", "w");
fprintf(fp, "%s %d %f/n", s, a, f);
/**********found**********/
______;
fp=fopen("file1.txt", "r");
/**********found**********/
fscanf(______, "%s%s%s", str, str1, str2);
fclose(fp);
a1=atoi(str1);
f1=atof(str2);
printf("/nThe result:/n/n%s %d %f/n", str, a1, f1);
}
main()
{char a[10]="Hello!"; int b=12345;
double c=98.76;
fun(a, b, c);
}
填空题写出下列程序的输出结果 ______。
main()
{ int=0;
while(n++<=1);
printf("%d,",n);
printf("%d",n++);
}
填空题若有以下程序: main() int,p,a=5; if(P=a!=0) printf("%d/n",p); else printf("%d/n",p+2); 执行后输出结果是 【8】 。
填空题以下程序的输出是{{U}} {{/U}}。 main() char str1[]="How do you do",*p1=str1; strcpy(str1+strlen(str1)/2"es she"); printf('%s//n",p1);
填空题以下程序的输出结果是{{U}} 【12】 {{/U}}。
float fun(int x,int y)
{ return(x+y);}
main()
{ int a=2,b=5,c=8;
printf("%3.0f/n",fun((int)fun(a+c,b),a-c));}
