例如,如果输入strl;=“abced”,str2=“fk”,则输出“fkced”。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仪在 main函数的横线上填入所编写的若干表达式或语句。
试题程序:
include<stdio.h>
include<string. h>
main ()
{
char strl [ 81], str2 [ 81 ];
char *pl=strl, *p2=str2;
clrscr ();
do
{
printf(" Input strl tn");
gets (strl);
printf(" Input str2 In");
gets (str2);
}while(【 】);
while(【 】)
*p1++=*p2++;
printf(" Display strl \n");
puts (【 】)
}
第1题
别式 (disc=b2-4ac)小于0,则要求重新输入a、b、c的值。
例如,当a=1,b=2,c=1时,方程的两个根分别是x1=-1.00, x2=-1.00。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。
试题程序:
include"math.h"
include <stdio.h>
main()
{
float a,b,C,disc,X1,x2;
clrscr();
do
{
printf("Input a,b,C:");
scanf("%f,%f,%f",&a,&b,ac);
disc=b*b-4*a*c;
if(disc<0)
printf("disc=%f\n Input again!
\n",disc);
}while(【 】);
printf("****+* the result *+*****\n");
x1=【 】;
x2=【 】;
printf("\nx1=%6.2f\nx2=%6.2f\n",x1/x2);
}
第2题
数放在s所指数组中,个数作为函数值返回。
请改正函数fun中指定部位的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
第3题
个字符的字符串。函数disp的功能是显示输出该单向链表中所有结点中的字符串。请填空完成函数disp。
include<stdio.h>
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);printf("\n");
}
第4题
下面程序的功能是将一个字符串str的内容颠倒过来,请填空。
include<string.h>
main()
{ infi,j, [13] ;char str[]={"1234567"};
for(i=0,j=strlen(str) [14] ;i<j;i++,j--)
{k=str[i];str[i]=str[i];str[j]=k;}
printf("%s\n",str);}
第5题
的数据,由main函数输出。
例如,若输入2 |若输入4
则输出: |则输出:
1 2 |1 2 3 4
2 4 |2 4 6 8
|3 6 9 12
|4 8 12 16
请改正程序函数中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!
第6题
其中,a指向原字符串,删除后的字符串存放在b所指的数组中,n中存放指定的下标。
例如,输入一个字符串world,然后输入3,则调用该函数后的结果为word。
注意:部分源程序给出如下。
请勿改动主函数main 和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include <stdio.h>
include <conio.h>
define LEN 20
void fun (char a[], char b [], int n)
{
}
main ()
{
char str1 [LEN], str2 [LEN];
int n ;
clrscr ();
printf ("Enter the string : \n") ;
gets (str1) ;
printf ("Enter the position of the string
deleted: ");
scanf ("%d", &n) ;
fun (str1, str2, n) ;
printf ("The new string is : %s \n",
str2) ;
}
第7题
k-1)*(2k+1))
例如,当k为10时,函数的值应为1.533852。
请改正程序中的错误,使它能得出正确的结果。
注童;不要改动main 函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <conio. h>
include <stdio. h>
include <math.h >
/**************found***************/
fun (int k)
{ iht n; float s, w, p, q;
n=1;
s=1.0;
while (n<=k)
{ w=2. 0*n;
p=w-1.0;
q=w+1.0;
s=s*w*w/p/q;
n++;
}
/***************found**************/
return s
}
main()
{ clrscr ();
printf ("%f\n ", fun (10));
}
第8题
插入一个空格。例如,在调用fun()函数之前给字符串a输入ABCDEFGHIJK,调用函数之后,字符串b中的内容则为ABC DEF GHI JK。
请改正程序中的错误,使它能得出正确的结果。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio. h>
void fun (char *p, char *b)
{ int i, k=0;
while (*p)
/*************found***************/
{ i=l;
/*************found***************/
while (i<3|| *P)
{
b[k]=*p;
k++; p++; i++;
}
if (*p)
/*************found***************/
{ b[k]= ' ';}
}
b[k]= '\0';
}
main ( )
{ char a[80],b[80];
printf ("Enter a string: "); gets (a);
printf ("The original string: ");
puts (a);
fun (a,b);
printf("\nThe string after insert
space: "); puts(b); printf("\n\n ");
}
第9题
请编写一个函数,函数的功能是删除字符串中的所有空格。
例如,主函数中输入“asd af aa z67”,则输出为“asdafaaz67”。
注意:部分源程序在文件PROGl.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
第10题
给定程序中,函数fun的功能是计算下式
例如:若形参e的值为1e-3,函数的返回值为0.551690。
请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。
注意:源程序存放在考生文件夹下的BLANKl.C中。不得增行或删行,也不得更改程序的结构!
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!