填空题设有定义“stmct{int a;float b;char c}abc,*p_abc=&abc;”,则对结构体成员a的引用方法可以是abc.a和p_abc______。
填空题【 】是一种信息隐蔽技术,目的在于将对象的使用者和对象的设计者分开。
填空题给定程序中,函数fun()的功能是:把形参s所指字符串中下标为奇数的字符右移到下一个奇数位置,最右边被移出字符串的字符绕回放到第一个奇数位置,下标为偶数的字符不动(注:字符串的长度大于等于2)。
例如,形参s所指的字符串为:abcdefgh,执行结果为:ahcbedgf。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在fun()函数的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
void fun(char*s)
{
int i,n,k;
char c;
n=0;
for(i=0;s[i]!="/0";i++)
n++;
if(n%2==0)
k=n-______;
else
k=n-______;
c=s[k];
for(i=k-2;i>=1;i=i-2)
s[i+2]=s[i];
s[1]=______;
}
void main()
{
char s[80]="abcdefgh";
printf("/nThe original string is:%s/n",s);
fun (s);
printf("/nThe result is:%s/n",s);
}
填空题下列给定程序中,函数fun的功能是:读入一个字符串(长度<20),将该字符串中的所有字符按ASCII码值升序排序后输出。例如,若输入"edcba",则应输出"abcde"。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<string.h>
#include<stdio.h>
void fun(char t[])
{
char c;
int i,j;
/*********found*********/
for(i=strlen(t);i;i--)
for(j=0;j<i;j++)
/*********found*********/
if(t[j]<t[j+1])
{
c=t[j];
t[j]=t[j+1];
t[j+1]=c;
}
}
main()
{
char s[81];
printf("/nPlease enter a character string:");
gets(s);
printf("/n/nBefore sorting:/n%s",s);
fun(s);
printf("/nAfter sorting decendingly:/n%s",s);
}
填空题以下定义的结构体类型包含两个成员,其中成员变量info用来存放整型数据;成员变量link是指向自身结构体的指针。请将定义补充完整。 struct node int info; 【10】 Link; ;
填空题Fibonacci数列中的头两个数是1和1,从第3个数开始,每个数等于前两个数之和。下述程序计算此数列的前20个数,且每行输出5个数,请填空。 #include<stdio.h> main() int f,f1=1,f2=1; int i; printf("%6d%6d",f1,f2); for(i=3;i<=20;i++) f= 【16】 ; printf("%6d",f); if( 【17】 ) printf("/n"); f1=f2; 【18】 ;
填空题有以下程序段,且变量已正确定义和赋值 for(s=1.0,k=1;k<=n;k++) s=s+1.0/(k*(k+1)); printf("s=%f",s); 请填空,使下面程序段的功能为完全相同 s=1.0;k=1; while(______)s=s+1.0/(k*(k+1));______; printf("s=%f",s);
填空题给定程序中,函数fun的功能是:将a所指3×5矩阵中第k列的元素左移到第0列,第k列以后的每列元素依次左移,原来左边的各列依次绕到右边。例如,有下列矩阵:若k为2,程序执行结果为:请在程序的下划线处填入正确的内容,使程序得出正确的结果。注意:部分源程序给出如下。不得增行或删行,也不得更改程序的结构!试题程序:#include<stdio.h>#defineM3#defineN5voidfun(int(*a)[N],intk){inti,j,p,temp;/********found********/for(p=1;p<=________;p++)for(i=0;i<M;i++){temp=a[i][0];/********found********/for(j=0;j<________;j++)a[i][j]=a[i][j+1];/********found********/a[i][N-1]=________;}}main(){intx[M][N]={{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5}},i,j;printf("Thearraybeforemoving:/n/n");for(i=0;i<M;i++){for(j=0;j<N;j++)printf("%3d",X[i][j]);printf("/n");}fun(x,2);printf("Thearrayaftermoving:/n/n");for(i=0;i<M;i++){for(j=0;j<N;j++)printf("%3d",x[i][j]);printf("/n");}}
填空题在一个容量为15的循环队列中,若头指针front=6,尾指针Year=9,则该循环队列中共有{{U}} 【1】 {{/U}}个元素。
填空题下列给定程序中,函数proc()的功能是:依次取出字符串中所有的字母字符,形成新的字符串,并取代原字符串。 例如,若输入的字符串是:ab232bd34bkw,则输出结果是:abbdbkw。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<stdlib.h> #include<stdio.h> #include<conio.h> void proc(char * str) int i, j; for(i=0, j=0; str[i]!='/0'; i++) //************found************* if((str[i]>='A' //************found************* str[j]="/0"; void main() char item[80]; system("CLS"); printf("/nEnter a string: "); gets(item); printf("/n/nThe string is:%s/n", item); proc(item); printf("/n/nThe string of changing is: %sin", item);
填空题下列给定程序中函数fun的功能是:用递归算法计算斐波拉契数列中第n项的值。从第1项起,斐波拉契数列为1、1、2、3、5、8、13、21、…
例如,若给n输入7,则该项的斐波拉契数值为13。 请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。
试题程序 #include
<stdio.h> long fun(int g) { /* * * * *found* *
* * */ switch(g); { case 0:return 0;
/* * * * *found* * * * */ case 1; case 2:return
1; } return (fun(g-1)+fun(g-2));
} void main() { long fib; int
n; printf("Input n:"); scanf("% d",
printf("n=% d/n", n);
fib=fun(n); printf("fib=% d/n/n", fib); }
填空题下列程序的输出结果是{{U}} 【10】 {{/U}}。
int t(int x,int y,nt cp,int dp)
{ cp=x*x+y*y;
dp=x*x-y*y;
}
main()
{ int a=4,b=3,c=5,d=6;
t(a,b,c,d);
printf("%d%d/n",c,d);
}
填空题请补充main()函数,该函数的功能是:从键盘输入一个长整数,如果这个数是负数,则取它的绝对值,并显示出来。例如,输入:-123456,结果为:123456。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void main()
{
long int num;
system("CLS");
printf("Enter the data: /n");
scanf(______);
printf("***the absolute value***/n");
if(num<0)
______
printf("/n/n");
printf(______);
}
填空题若有以下定义: char a;int b; float c;double d; 则表达式a*b+d-c值的类型为 【7】 。
填空题下面程序的输出结果是 【9】 。 main( ) int i=3,j=2; char * a="DCBA"; printf("%c%c/n",a[i],a[j])
填空题下面程序有两个printf语句,如果第一个printf语句输出的是194,则第二个printf语句的输出结果是{{U}} 【13】 {{/U}}。
main()
{ int a[10]={1,2,3,4,5,6,7,8,9,0},*p;
p=a;
printf("%x/n",p);
printf("%/n",p+9);
}
填空题存储300个16×16点阵的汉字信息需要 【5】 字节。
填空题下面程序中函数creat用于建立一个带头结点的单向链表,新产生的结点总是插在链表的末尾,单向链表的头指针作为函数值返回。将程序补充完整。 #include<stdiao.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】 malloc(sizeof(struct list)); p->data=ch;q->next=p;q=p;ch=getchar(); p->next='/0'; 【20】 ;
填空题fun函数的功能是:首先对a所指的N行N列的矩阵,找出各行中的最大的数,再求这N个最大值中的最小的那个数作为函数值返回。请填空。 #include<stdio.h> #define N 100 int fun(int(*a)[N]) int row,col,max,min; for(row=0;row<N;row++) for(max=a[row][0],col=1;col<N;col++) if(______)max=a[row][col]; if(row==0)min=max; else if(______)min=max; return min;
填空题某学生的记录由学号、8门课程成绩和平均分组成,学号和8门课程的成绩已在主函数中给出,请编写函数fun(),其功能是:求出该学生的平均分,并放入记录的ave成员中。
例如,学生的成绩是85.5、76、69.5、85、91、72、64.5、87.5,则他的平均分应为78.875。
注意:部分源程序给出如下。
请勿改动主函数main()和其他函数中的任何内容,仅在函数fun()的花括号中填入你编写的若干语句。
试题程序 #include
<stdio.h> #define N 8 typedef struct
{ char num[10]; double s[N];
double ave; } STREC; void fun(STREC
*a) { } void main()
{ STREC s={"GA005", 85.5,76,69.5,85,91,72,64.5,87.5};
int i; fun( printf("The % s's student
data:/n", s.num); for(i=0; i<N; i++) printf("%
4.1f/n", s.s[i]); printf("/nave=% 7.3f/n", s.ave);
}