from forward to aft
from aft to forward
at master's option
as per owner's instruction
第1题:
Your vessel has lifeboats on both sides. Lifeboat No. 2 is located ________.
A.forward of lifeboat No. 4 on the starboard side
B.forward of lifeboat No. 4 on the port side
C.aft of lifeboat No. 1 on the starboard side
D.All of the above
第2题:
函数ReadDat()实现从文件IN.dat中读取1000个十进制整数到数组xx中;请编写函数 Compute()分别计算出数组xx中奇数的个数odd、偶数的个数even,以及所有数的平均值aver和方差totfc的值。最后调用函数WriteDat(),把结果输出到OUT. dat文件中。
计算方差的公式如下:
原始数据文件存放的格式是:每行存放10个数(每个数均大于0且小于等于2000),并用逗号隔开。
注意:部分源程序已经给出。请勿改动主函数main()、读函数ReadDat()和输出数据函数 WriteDat()的内容。
include <stdio. h>
include <stdlib. h>
include <string. h>
define MAX 1000
int xx[MAX], odd = 0, even = 0;
double aver = 0.0, totfc = 0.0;
void WriteDat(void);
int ReadDat(void)
{ FILE *fp;
int i, j;
if ((fp = fopen("IN. dat", "r")) == NULL)
return 1;
for (i=0; i<100; i++)
{ for (j=0; j<10; j++)
fscanf(fp, "%d,", &xx[i*10+j]);
fscanf(fp, "\n");
if (feof(fp))
break;
}
fclose(fp);
return 0;
}
void Compute(void)
{
}
void main ()
{ int i;
for (i=0; i<MAX; i++)
xx[i] = 0;
if (ReadDat())
{
printf (" 数据文件 IN. dar 不能打开! \007\n");
return;
}
Compute ( );
printf("odd=%d\neven=%d\naver=%f\ntotfc=%f\n", odd, even, aver, totfc);
WriteDat ();
}
void WriteDat(void)
{ FILE *fp;
fp = fopen("OUT.dat", "w");
fprintf(fp, "%d\n%d\n%f\n%f\n", odd, even, aver, totfc);
fclose (fp);
}
第3题:
对输入一个整数进行判断,若是偶数,输出even,否则输出odd,在子函数fun2功能是判定整数是否为偶数,若是偶数,返回1,否则返回0int fun2(int x){if(x%2==0);return 0;}main(){int n;scanf("%d",&n);ifprintf("even\n");else printf(odd\n");}
第4题:
public void test(int x) { int odd = x%2; if (odd) { System.out.println(“odd); } else { System.out.println(“even”); } } Which statement is true?()
第5题:
Lifeboats are numbered ______.Odd numbers to starboard and even numbers to port.
A.from forward to aft
B.from aft to forward
C.at master's option
D.as per owner's instruction
第6题:
A.Compilationfails.
B.“odd”willalwaysbeoutput.
C.“even”willalwaysbeoutput.
D.“odd”willbeoutputforoddvaluesofx,and“even”forevenvalues.
E.“even”willbeoutputforaddvaluesofx,and“odd”forevenvalues.
第7题:
请编制函数ReadDat()实现从文件IN93.DAT中读取1000个十进制整数到数组xx中。请编制函数 Compute()分别计算出xx中奇数的个数odd、偶数的个数even、平均值aver及方差totfc的值,最后调用函数WriteDat()把结果输出到OUT93.DAT文件中。
计算方差的公式如下:
原始数据的存放格式是:每行存放10个数,并用逗号隔开(每个数均大于0且小于等于2000)。
注意:部分源程序已给出。
请勿改动主函数main()和写函数WriteDat()的内容。
试题程序:
include<stdio.h>
include<stdlib.h>
include<string.h>
define MAX 1000
int xx[MAX],odd=0,even=0;
double aver=0.0,totfc=0.0;
void WriteDat(void);
int ReadDat(void)
{
FILE *fp;
if((fp=fopen("IN93.DAT","r"))==NULL
return 1;
fclose(fp);
return O;
}
void Compute(void)
{
}
void main( )
{
int i;
for(i=O;i<MAX;i++)
xx[i] =0;
if (ReadDat ( ) )
{
print f ("数据文件IN93.DAT不能打开! \007\n");
return;
}
Compute();
printf( "ODD=%d\nEVEN=%d\nAVER=%lf\nTOTFC=%lf\n",
odd, even,aver,totfc);
WriteDat();
}
void WriteDat(void)
{
FILE *fp;
int i;
fp=fopen("OUT93.DAT","w");
fprintf(fp,"%dln%dln%lf\n%lfkn",odd,even,aver,totfc);
fclose(fp);
}
第8题:
Preferred channel buoys indicate the preferred channel to transit by ______.
A.odd or even numbers
B.the color of their top band
C.the location of the buoy in the channel junction
D.the buoy’s light rhythms
第9题:
第10题:
有一个表格,如果匹配所有行数为偶数的,用even实现,奇数的用odd实现。()