![](https://static.youtibao.com/asksite/comm/h5/images/m_q_title.png)
以下程序调用函数swap_p将指针s和t所指单元(a和b)中的内容交换,请填空。 main() { int a=
以下程序调用函数swap_p将指针s和t所指单元(a和b)中的内容交换,请填空。 main() { int a=10,b=20,*s,*t; s=&a;t=&b; swap_p(【 】); printf("%d%d,a,b");} swap_p(int**ss,int**tt) { int term; term=**ss; **ss=**tt; **tt=term; }
![](https://static.youtibao.com/asksite/comm/h5/images/solist_ts.png)
以下程序调用函数swap_p将指针s和t所指单元(a和b)中的内容交换,请填空。 main() { int a=10,b=20,*s,*t; s=&a;t=&b; swap_p(【 】); printf("%d%d,a,b");} swap_p(int**ss,int**tt) { int term; term=**ss; **ss=**tt; **tt=term; }
A.函数fopen()调用形式错误
B.输入文件没有关闭
C.函数fgetc()调用形式错误
D.文件指针stdin没有定义
对于以下函数声明
void fun(int array[4],int+ptr);以下叙述中正确的是()。
A.array,ptr都是指针变量
B.调用fun函数时,实参的值将逐一复制给array
C.调用fun函数时,array按值传送,ptr按地址传送
D.array是数组,ptr是指针,它们的性质不同
以下程序调用findmax()函数返回数组中的最大值。请填空完成此函数。
include〈iostream〉
using namespace std;
int findmax(int*a,int n)
{
int +p、*s;
for(p=a,s=a;p-a〈n;p++)
if(【 】)
*s=*p;
return(*S);
}
int main()
{
int x[5]={12,21,14,16};
cout〈〈findmax(X,5)〈〈end1;
return 0;
}
A.(*f1)(a)
B.*f1(*s)
C.un(&a)
D.h=*f1(s)
下列程序中的函数strcpy2()实现字符串两次复制,即将t所指字符串复制两次到s所指内存空间中,合并形成一个新字符串。例如,若t所指字符串为:efgh,调用strcpy2后,s所指字符串为:efghefgh。请填空。#include <stdio.h>#include <string.h>void strcpy2(char *s,char *t){char *p=; while(*s++=*t++); s=s-1; while(=*p++);}main(){char str1[100]="abcd",str2[]="efgh"; strcpy2(str1,str2); printf("%s\n",strl);}
A.该程序完全正确
B.以上说法都不正确
C.该程序有错,只要将语句swap(&a,&b);中的参数改为a,b即可
D.该程序有错只要将swap()函数中的形参p、q和变量均定义为指针即可
若有函数 void fun(double a[]。int*n) {…} 以下叙述中正确的是()。
A.调用fun函数时只有数组执行按值传送,其他实参和形参之间执行按地址传送
B.形参a和n都是指针变量
C.形参a是一个数组名,n是指针变量
D.调用fun函数时将把double型参数组元素一一对应地传送给形参a数组
请编写函数fun(),其功能是:将s所指字符串中下标为偶数的字符删除,串中剩余字符形成的新串放在t所指数组中。
例如,当s所指字符串中的内容为ABCDEFGHIJK,则在t所指数组中的内容应是BDFHJ。
注意:部分源程序给出如下。
请勿改动主函数main口其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<conio. h>
include<stdio .h>
include<string.h>
void fun(char *s,char t[])
{
}
main ()
char s[l00] ,t[l00];
clrscr ();
printf("%nPlease enter string S: ");
scanf("%s ",s);
fun(s,t);
prlntf("\nThe result is:%s\n ",t);
}
在给定程序中,函数fun的功能是:根据以下公式求π值,并作为函数值返回。
例如,给指定精度的变量eps输入0.0005时,应当输出Pi=3.140578。 请改正程序中的错误,使它能得出正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 include include include double fun(double eps) {double s,t; int n=1; s=0.0; /************found************/ t=0; while(t>eps) {s+=t; t=t*n/(2*n+1); n++; } /************found************/ return(S); } main() {double x; printf("\nPlease enter a preciSion:")j scanf(”%1f”,&x); printf("\neps=%1f,Pi=%1f\n\n",x,fun(x)); )
执行以下程序后,test.txt文件的内容是(若文件能正常打开)()。 #include<stdio.h> main() { FILE*fp; char*s1="Fortran",*s2="Basic"; if((fp=fopen("test.txt","wb"))==NULL) { printf("Can't open test.txt file\n");exit(1);} fwrite(s1,7,1,fp);/*把从地址s1开始的7个字符写到fp所指文件中*/ fseek(fp,0L,SEEK_SET);/*文件位置指针移到文件开头*/ fwrite(s2,5,1,fp); fclose(fp); }
A.Basican
B.BasicFortran
C.Basic
D.FortranBasic