填空题以下程序的输出是 【7】 。 main() char str1[]="How do you do",*pl=str1; strcpy(str1+strlen(str1)/2,"es she"); intf("%s/n",p1);
填空题str是全部由小写字母字符和空格字符组成的字符串,由 num传入字符串的长度。请补充函数fun(),该函数的功能是:统计字符串str中的单词个数,结果由变量num传回。每个单词之间都由空格隔开,并且字符串str开始不存在空格。
例如:str=“how do you do”,结果为:num=4。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdio.h>
#define N 80
void fun(char *s,int *num)
{
int i,n=0;
for(i=0;{{U}} 【1】 {{/U}};i++)
{
if(s[i]>='a',
fun(str,&num);
printf("The number of word is:
%d/n/n",num);
}
填空题下面程序的输出结果是______。 #include main() char c[9]='T','h','a''/0,",'y','0','u'; printf("%s/n",c);
填空题mystrlen函数的功能是计算str所指字符串的长度,并作为函数值返回。请填空。 int mystrlen(char*str) int i; for(i=0; 【14】 !='/0';i++); return(i);
填空题实现算法所需的存储单元多少和算法的工作量大小分别为算法的{{U}} 【1】 {{/U}}。
填空题给定程序中函数fun的功能是:首先把b所指字符串中的字符按逆序存放,然后将a所指字符串中的字符和b所指字符串中的字符,按排列的顺序交叉合并到c所指数组中,过长的剩余字符接在c所指的数组的尾部。例如,当a所指字符串中的内容为"abcdefg",b所指字符串中的内容为"1234"时,c所指数组中的内容应为"a4b3c2d1efg";而当a所指字符串中的内容为"1234",b所指字符串的内容为"abcdefg"时,c所指数组中的内容应该为"1g2f3e4dcba"。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<string.h>
void fun(char*a,char*b,char*c)
{
int i,j;char ch;
i=0;j=strlen(b)-1;
/*********found*********/
while(i>j)
{ch=b[i];b[i]=b[j];
b[j]=ch;
i++;j--;
}
while(*a||*b){
/*********found*********/
If(*a)
{*c=*a; c++; a++;}
if(*b)
{*c=*b;c++;b++;}
}
*c=0;
}
main()
{
char s1[100],s2[100],t[200];
printf("/nEnter s1 string:");
scanf("%s",s1);
printf("/nEnter s2 string:");
scanf("%s",s2);
fun(s1,s2,t);
printf("/nThe result is:%s/n",t);
}
填空题
[13] 0[14];i<=100;[15]sum
填空题下列给定程序是建立一个带头结点的单向链表,并用随机函数为各结点赋值。函数fun的功能是将单向链表结点(不包括头结点)数据域为偶数的值累加起来,并且作为函数值返回。
请改正函数fun中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef struct aa
{int data;
struct aa*next;
}NODE;
int fun(NODE*h)
{int sum=0;
NODE * p;
p=h->next;
/*********found*********/
while(p->next)
{if(p->data%2==0)
sum+=p->data;
/*********found*********/
p=h->next;
}
return sum;
}
NODE*creatlink(int n)
{
NODE*h,*p,*s;
int i;
h=p=(NODE*)malloc(sizeof(NODE));
for(i=1;i<n;i++)
{
s=(NODE*)malloc(sizeof(NODE));
s->data=rand()%16;
s->next=p->next;
p->next=s;
p=p->next;
}
p->next=NULL;
return h;
}
outlink(NODE*h)
{NODE*p;
p=h->next;
printf("/n/n The LIST:/n/nHEAD");
while(p)
{printf("->%d",p->data);
p=p->next;}
printf("/n");
}
void main()
{NODE*head;int sum;
system("CLS");
head=creatlink(10);
outlink(head);
sum=fun(head);
printf("/nSUM=%d",sum);
}
填空题以下函数rotate的功能是:将a所指N行N列的二维数组中的最后一行放到b所指二维数组的第0列中,把a所指二维数组中的第0行放到b所指二维数组的最后一列中,b所指二维数组中其他数据不变。 #define N 4 void rotate(int a[][N], int b[][N]) int i, j; for(i=0;i<N;i++) b[i][N-1] = (13) ; (14) = a[N-1][i];
填空题若有如下程序: void sub() static int x=8; x/=2;printf("%d",x); main() int m; for(m=0;m<2;m++) sub(); 则程序运行后的输出结果是 【9】 。
填空题以下程序将数组a的4个元素和数组b的6个元素写到名为letter.dat的二进制文件中,请填空。 #include<stdio.h> main() FILE*fp; char a[4]="1234",b[6]="abcdef"; if((fp=fopen(" 【19】 ","wb"))==NULL)exit(0); fwrite(a,sizeof(char),4,fp); fwrite(b, 【20】 ,1,fp); fclose(fp);
填空题以下程序运行后的输出结果是{{U}} 【11】 {{/U}}。
main()
{ int i,n[]={0,0,0,0,0};
for(i=1;i<=4;i++)
{ n[i]=n[i-1]*2+1;
printf("%",n[i]);
}
填空题请补充函数proc(),该函数的功能是:把从主函数中输入的由数字字符组成的字符串转换成一个无符号长整数,并且逆序输出。结果由函数返回。例如,输入:1234567,结果输出:7654321。
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在函数proc()的横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
unsigned long proc(char*str)
{
unsigned long t=0;
int k;
int i=0;
i=strlen(str);
for(______; i>=0; i--)
{
k=______;
t=______;
}
return t;
}
void main()
{
char str[8];
system("CLS");
printf("Enter a string made up of "0"to "9" digital character: /n");
gets(str);
printf("The string is: %s/n", str);
if(strlen(str)>8)
printf("The string is too long!");
else
printf("The result: %lu/n",
proc(str));
}
填空题存储结点中数据域占用的存储量与整个结点占用存储量之比称为______。
填空题若用0至9之间不同的三个数构成一个三位数,下面程序将统计出共有多少种方法。请填空。 #include<stdio.h> main() int i,j,k,count=0; for(i=0;i<=9;i++) for(j=0;i<=9;j++) if( 【18】 )continue; else for(k=0;k<=9;k++) if( 【19】 )count++; printf("%d",count);
填空题给定程序中,函数fun的功能是:将形参s所指字符串中所有ASCII码值小于97的字符存入形参t所指字符数组中,形成一个新串,并统计出符合条件的字符个数作为函数值返回。
例如,形参s所指的字符串为:Abc@1x56*,程序执行后,f所指字符数组中的字符串应为:A@156*。
请在程序的下划线处填入正确的内容,使程序得出正确的结果。
注意:部分源程序给出如下。
不得增行或删行,也不得更改程序的结构!
试题程序:
#include<stdio.h>
int fun(char*s,char*t)
(int n=0;
while(*s)
{if(*s<97)
{
/********found********/
*(t+n)=______;n++;}
/********found********/
______;
}
*(t+n)=0;
/********found********/
return______;
}
}
main()
(char s[81],t[81];int n;
printf("/nEnter a string:/n");
gets(s);
n=fun(s,t);
printf("/nThere are%d letter which ASCII code is less than 97:%s/n",n,t);
}
填空题以下函数fun的功能是返回str所指字符中中以形参c中字符开头的后续字符串的首地址,例如:str所指字符串为“Hello!”,c中的字符为'e',则函数返回字符串"ello!"的首地址。若 str所指字符串为空中或不包含c中的字符,则函数返回NULL。请填空。 char *fun (char *str,char c) int n=0;char*p=str; if(p!=NULL) while(P[n]! =c&&p[n]! ='/0')n++; if(p[n]=='/0')retum NULL; return( 【8】 );
填空题想通过以下输入语句给x赋值2,给y赋值3,则输入数据的形式应该是______。
int x,y;
scanf("x=%d,y=%d",&x,&y);
填空题选择程序中的输入输出语句,以满足题目给定的输入输出数据形式。 main() int a;float b; 【11】 【12】 输入形式:3.52<空格>6<回车> 输出形式:a*b=21.12
填空题以下程序运行后的输出结果是______。 #include<stdio.h> main() char a; for(a=0;a<15;a+=5) putchar(a+'A'); printf("/n");