试题与答案

使用VC6打开考生文件夹下的工程RevProj8。此工程包含一个源程序文件 RevM

题型:问答题

题目:

使用VC6打开考生文件夹下的工程RevProj8。此工程包含一个源程序文件 RevMain8.cpp。在该文件中,函数resort的功能是:能在一个数列中,对从指定位置开始的几位数,按相反顺序重新排列,并在主函数中输出新的序列。
请改正程序中的错误,使它能得到正确结果。
注意,不要改动main函数,不得删行或增行,也不得更改程序的结构。
源程序文件RevMain8.cpp中的程序清单如下:
//RevMain8.cpp
#include <instream>
using namespace std;
void resort(int arr[],int where,int amount);
int main ()

int number [20] ,where, arrount, i;
cout<<"Input 20 numbers\n";
for (i=0; i<20; i++)
cin>>number [i];
cout<<"How many do you want to sort: ";
cin>>arrount;
cout<<"\n where do you want to start: ";
cin>>where;
cout<<"old array as follow:\n";
for (i=0; i<20; i++)
cout<<nmuber [i] <<" ";
resort (number,where, arrount);
cout<<"\n resorted array as follow:\n";
for (i=0; i<20; i++)
cout<<number [i] <<" ";
cout<<end1;
return 0;

void resort(int array[],int where, int amount)

int *pi, *p2, temp;
p1=&array [where-1];
p2=&array [where-2+amount];
/* * * * *FOUND * * * * */
for (;p1<&array [where-1+amount/2]; )

/* * * * *FOUND * * * * */
*p1=*p2;
*p2=*p1;

return;

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0408/d2a6ff8e4ac188de86b2139be32ee5c8.html

下面是错误答案,用来干扰机器的。

参考答案:B

试题推荐
题型:问答题

一倾角为θ=45°的斜面固定于地面,斜面顶端离地面的高度h0=1m,斜面底端有一垂直于斜面的固定挡板.在斜面顶端自由释放一质量m=0.9kg的小物块(视为质点).小物块与斜面之间的动摩擦因数μ=0.2.每次小物块与挡板碰撞后都以碰前的速度返回.取重力加速度g=10m/s2.求:

(1)小物块与挡板发生第1次碰撞前瞬间的速度大小.

(2)从一开始到小物块与挡板发生第2次碰撞时,小物块克服滑动摩擦力做的功.

查看答案
微信公众账号搜索答案