填空题以下程序中函数fun的功能是:构成一个如图所示的带头结点的单向链表,在结点的数据域中放入了具有两个字符的字符串。函数disp的功能是显示输出该单链表中所有结点中的字符串。请填空完成函数
disp。
#include
typedef struct node/*链表结点结构*/
{char sub[3];
struct node * next;
}Node;
Node fun(char S) /*建立链表*/
{ ……}
void disp(Node *h)
{Node*P;
P=h->next;
while(【 】)
{printf("%s\n",P->sub);P=【 】; }
}
main()
{Node *hd;
hd=fun();disp(hd);prinff("\n");
}
填空题函数fun的功能是:将一副扑克牌编号为1,2,3,…,53,54,以某种特定的方式洗牌,这种方式是将这副牌分成两半,然后将它们交叉,并始终保持编号为1的牌在最上方,如第一次这样洗牌后的结果为:1,28,2,29,…,53,27,54。两次洗牌后的结果为:1,41,28,15,2,42…,53,40,27,14,54。
程序的功能是:输出经过n次这样洗牌后的结果。
请在程序的下画线处填入正确的内容,并把下画线删除,使程序得出正确的结果。
注意:不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
void fun(int a[55],int n)
{int i,k;
/**********found**********/
int______[55];
for(i=0;i<n;i++)
{for(k=1;k<=27;k++)
{b[2*k-1]=a[k];
/**********found**********/
b[______*k]=a[k+27];
for(k=1;k<=54;k++)
/**********found**********/
a[k]=______;
}
}
main()
{int m,a[55],i;
for(i=1;i<55;i++)a[i]=i;
printf("请输入洗牌次数:");scanf("%d",
fun(a,m);
for(i=1;i<55;i++)printf("%d,",a[i]);
printf("/n");
}
填空题下列程序的输出结果是______。 #include<stdio.h> int t(int x,int y,int cp,int dp) cp=x*x+y*y; 如:dp=x*-y*y; main() int a=1,b=8,c=7,d=9; t(a,b,c,D) ; printf("%d%d/n",c,D) ;
填空题以下程序中函数huiwen的功能是检查一个宁符串是否是回文,当字符串是回文时,函数返回字符串:yes!,否则函数返回字符串:no!,并在主函数中输出。所谓回文即正向与反向的拼写都一样,例如:adgda。请填空______。 # include <string. h> chat * huiwen(chat * str) char *p1, *p2; int i, t=0; p1=str; p2= 【13】 ; for(i=0; i<=strlen(str)/2; i++) if(*p1++!=*p2--)t=1; break; if(! t或t!=0)return("yes!"); else return("no!"); main() char str[50]; printf("Input: "); scanf("% s", str); printf("% s/n", huiwen(str));
填空题若有语句
int i=-19,j=i%4;
printf("%d/n",j);
则输出的结果是【 】。
填空题以下程序的输出结果是 【12】 。 #include <stdio.h> main() int a=1234; float b=123.456; double c=12345.54321; printf("/n%2d,%2.1f,%2.11f",a,b,C);
填空题若i、j为int类型,则以下程序段内循环体的总执行次数是{{U}} 【12】 {{/U}}。
for(i=5;i;i--)
for(j=0;j<3;j++)
{
}
填空题以下程序运行后输入3,abcde<回车>,则输出结果是 【19】 。 #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);
填空题已知字符'A'的ASCII代码值为65,以下程序运行时若从键盘输入:B33 <回车>,则输出结果是{{U}} 【9】 {{/U}}。
#include <stdio.h>
main( )
{ char a,b;
a = getchar( ) ;seanf( "% d" ,
a=a-'A' +'0';b=b* 2;
prinff( "% c % c /n" ,a,b);
}
填空题给定程序中,函数fun的功能是:计算出带有头结点的单向链表中各结点数据域中值之和作为函数值返回。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
#include<stdio.h>
#include<stdlib.h>
#define N 8
typedef struct list
{int data;
struct list *next;
}SLIST;
SLIST*creatlist(int*);
void outlist(SLIST*);
int fun(SLIST*h)
{SLIST *p;int s=0;
p=h->next;
while(p)
{
/**********found**********/
s+=P->______;
/**********found**********/
p=p->______;
}
return s;
}
main()
{SLIST*head;
int a[N]={12,87,45,32,91,16,20,48};
head=creatlist(a);outlist(head);
/**********found**********/
printf("/nsum=%d/n",fun(______));
}
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("The list is NULL!/n");
else
{printf("/nHead");
do
{printf("->%dtt,p->data);p=p->next;}
while(p!=NULL);
printf("->End/n");
}
}
填空题函数my_cmp()的功能是比较字符串s和t的大小,当s等于t时返回0,否则返回s和t的第一个不同字符的ASCII码差值,即s>t时返回正值,当s<t时返回负值。请填空。
my_cmp(char *s,char*t)
{ while(*s==*t)
{ if(*s=="/0")return 0;
++s; ++t;
} return______;
}
填空题若有如下程序:
#include"stdio.h"
main()
{char s[30];
strcpy(&s[0],"abc"); strcpy(&s[1],"de"); strcpy(&s[2],"f");
printf("%s/n",s); }
则程序运行后的输出结果是{{U}} 【7】 {{/U}}。
填空题下列给定程序中,函数fun()的功能是:根据输入的3个边长(整型值),判断能否构成三角形:若能构成等边三角形,则返回3,若是等腰三角形,则返回2,若能构成三角形则返回1,若不能,则返回0。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include <math. h> int fun(int a, int b, int c) if (a+b>c else if(a==b|| b==c||a==c) return 2; /*************found**************/ else return 3; else return 0; main ( ) int a,b, c, shape; printf("/nInput a,b,c: "); scanf ("%d%d%d", printf ("/na=%d, b=%d, c=%d/n",a,b,c); shape=fun (a,b, c); printf ("/n/nThe shape : %d/n", shape);
填空题已有定义如下: struct node int data; struct node *next; *p; 以下语句调用malloc函数,使指针p指向一个具有struct node类型的动态存储空间。请填空。 p=(struct node *)malloc( 【19】 );
填空题请补充函数fun(),该函数的功能是:把一个整数转换成字符串,并倒序保存在字符数组str中。例如:当n=13572468时,str=-“86427531”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。
试题程序:
#include <stdio.h>
#include <conio.h>
#define N 80
char str[N];
void fun(long int n)
{
int i=0;
while({{U}} {{U}} {{/U}}{{/U}})
{
str[i]={{U}} {{U}} {{/U}}{{/U}};
n/=10;
i++;
}
{{U}} {{U}} {{/U}}{{/U}};
}
main()
{
long int n=13572468;
clrscr();
printf("*** the origial data ***/n");
printf("n=%ld",n);
fun(n);
printf("/n%s",str);
}
填空题以下程序段用于构成一个简单的单向链表。请填空。 struet STRU int x,y; float rate; 【14】 p; a,b; a.x=0; a.y=0;a.rate=0;a.p=&b; b.x=0;b.y=0;b.rate=0;b.p=NULL;
填空题有如下图所示的双链表结构,请根据图示完成结构体的定义:structaaintdata;【15】node;
填空题以下程序中函数fun的功能是:统计person所指结构体数组中所有性别(sex)为M的记录的个数,存入变量n中,并作为函数值返回。请填空。 #include #define N 3 typedef struct int num;char nam[10];char sex;SS; int fun(SS person[] int i,n=0; for(i=0;i<N;i++) if( [14] =='M')n++; return n;
填空题假定变量x为int类型,请以最简单的形式写出与逻辑表达式!x等价的C语言关系表达式 【7】 。
填空题以下程序运行后的输出结果是 【15】 。#include <stdio.h>#include <string.h>char * ss(char * s) char * p,t; p=s+1:t= *s: whilet * p) *(,p-1) = *p; p++; * (p-1) =t; return s : main ( ) char * p,str[10] =" abedefgh"; p = ss(str); printf( "% s /n". p):
