阅读以下说明和c++码,将应填入(n)处的字名写在的对应栏内。
[说明] 以下函数完成求表达式
的值,请填空使之完成此功能。
float sum ( float x )
{ float s=0.0;
int sign = 1;
(1);
for(inti=1;(2); i+ +)
{
t=t*x;
s=s+(3);
sign = - sign;
(4);
}
第1题:
第2题:
试题三(共 15 分)
阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。
第3题:
阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。
[说明1]
函数void fun(char*w,char x,int*n)用来在w数组中插入x,w数组中的数已按由小到大顺序存放,n指存储单元中存放数组中数据的个数,插入后数组中的数仍有序。
[C函数1]
void fun(char*W,char x,int*n)
{ int i,P;
p=0;
w[*n]=x;
while(x>w[p]) (1) ;
for(i=*n,i>p;i--)w[i]=(2);
w[p]=x;
++*n;
}
[说明2]
函数void revstr(char*s)将字符串s逆置。例如:字符串“abcde”,经过逆置后变为“edcba”。
[C函数2]
void revstr(char*s)
{ char*p,c;
if(s==NULL)return;
p=(3); /*p指向字符串s的最后一个有效字符*/
while(s<p){ /*交换并移动指针*/
C=*s;
(4)=*p;
(5)=c;
}
}
第4题:
阅读以下说明和Visual Basic 码,将应填入(n)处的字名写在的对应栏内
[说明] 这是一个用户名校验程序,如用户名正确,即输出欢迎字样,否则,弹出警告窗并直接退出程序。下面是实现上述功能的程序,请填空。“Option Explicit”此语句的作用:强制显示声明
Dim UserName (2) As String
Dim Flag As Boolean
(1)
Private Sub Form. _ Load( )
UserName (0) = "AA": UserName (1) = "BB": UserName(2) = "CC"
Flag = False
inputName = InputBox( “请输入名称:“,”身份确认”“,”)
Dim i As Integer
For i = 0 To False
If inputName = UserName(i) Then
(2)
End If
Next i
If (3) Then
MsgBox “用户身份确失败!退出应用”, vbOKOnly, “警告”
End
End If
End Sub
Private Sub Form_ Paint( )
(4)
End Sub
第5题:
阅读以下说明和C语言函数,将应填入(n)处的字句写在对应栏内。
[说明]
编写一个函数,输入为偶数时,调用函数求1/2+?/+…+1/n,当输入n为奇数时,调用函数1/1+1/3+…+1/n (利用指针函数)。
[函数]
include "stdio. h",
main()
{
float peven (),podd (),dcall ();
float sum;
int n;
while (1)
{
scanf("%d",&n);
if (n>1)
break;
}
if(n%2==0)
{
printf("Even="):
(1);
}
else
{
pfinff("Odd=");
(2);
}
printf("%f",sum);
}
float peven (int n)
{
float s;
int i
s=1;
for(i=2;i<=n;i+=2)
(3);
return (s);
}
float podd (n)
int n;
{
float s;
int i;
s=0;
for(i=1 i<=n;i+=2)
(4);
return (s);
}
float dcall(fp,n)
float (*fp) ();
int n;
{
float s;
(5);
returu (s);
}
第6题:
阅读以下说明和C++码,将相应的文字填入(n)处,写在对应栏内。
[说明]
以下代码实现了对象引用作为函数参数,仔细阅读以下代码,分析运行结果,填入(n)处。
[代码]
include<iostream.h>
class Sample
{
int x,y;
public:
Sample() {x=y=0; }
Sample (int i, int j ) {x=i; y=j; }
void copy ( Sample &s ).,
void setxy ( int i, int j ) {x=i; y=j; }
void print ( {cout<<"x="<<x<<end1 ; cout <<"y="<<y<<end1;
};
void Sample: copy ( Sample &s )
{
X=S.X;
y=s.y;
}
void func ( Sample s1, Sample &s2 )
{
s1.setxy ( 10,20 );
s2.setxy ( 30,40 );
}
void main ( )
{
Sample p ( 1,2 ) ,q;
q.copy ( p );
time ( p,q );
p.print ( );
q.print ( );
}
运行结果
(1)
(2)
(3)
(4)
第7题:
阅读以下说明和C语言函数,将应填入(n)处的字句写在对应栏内。
[说明]
完成以下中序线索化二叉树的算法。
[函数]
Typedef int datatype;
Typedef struct node {
Int ltag, rtag;
Datatype data;
*lchild,* rchild;
}bithptr;
bithptr pre;
void inthread ( p );
{if
{inthread ( p->lchild );
if ( p->lchild==unll ) (1);
if ( P->RCHILD=NULL) p->rtag=1;
if (2)
{if (3) pre->rchild=p;
if ( p->1tag==1 )(4);
}
INTHREAD ( P->RCHILD );
(5);
}
}
第8题:
阅读以下说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。
【说明】
以下程序为求行列式X(5,5)的值S。
【Visual Basic代码】
Private Function col ( byval x ( 5,5 ) as integer ) as long
dim fesult as long
dim temp as long
dim I as integer
dim j as integer
dim k as imeger
result = 0
for I = to 5
(1)
for j = 1 to 5
if I+j>6 then
k= ( 1+j ) mod 5
else
k=1
endif
temp=temp*x ( k,j )
(2)
result=(3)
(4)
(5)
End function
第9题:
函数 void fun(float *sn, int n)的功能是:根据以下公式计算S,计算结果通过形参指针sn传回;n通过形参传入,n的值大于等于0。请填空。
void fun( float *sn, int n)
{ float s=0.0, w, f=-1.0;
int i=0;
for(i=0; i<=n; i++)
{ f=( )* f;
w=f/(2*i+1);
s+=w; }
( )=s;}