niusouti.com

写出下列程序的运行结果【】。 include void func(double x, int &part1, double写出下列程序的运行结果【 】。include<iostream. h>void func(double x, int &part1, double &part2){part1=int(x)+500:part2=(x+500-part1)*100;}void main( ){int n;double x, f;x=1001. 0103;func (x, n, f):cout<<"Part

题目
写出下列程序的运行结果【】。 include void func(double x, int &part1, double

写出下列程序的运行结果【 】。

include<iostream. h>

void func(double x, int &part1, double &part2){

part1=int(x)+500:

part2=(x+500-part1)*100;

}

void main( ){

int n;

double x, f;

x=1001. 0103;

func (x, n, f):

cout<<"Part 1="<<n<<" , part2="<<f<<end1

}


相似考题
更多“写出下列程序的运行结果【】。 include<iostream. h> void func(double x, int &amp;part1, double ”相关问题
  • 第1题:

    阅读下面程序:include template class TAdd{private:T x, y;public:TAdd(T

    阅读下面程序:

    include <iostream.h>

    template <class T>

    class TAdd

    {

    private:

    T x, y;

    public:

    TAdd(T a, T b)

    {

    x=a;

    y=b;

    }

    T add()

    {

    return x +y;

    }

    };

    void main( )

    {

    TAdd<int>a(5,6);

    TAdd<double>b(2.4,5.8);

    cout<<"s1 ="<<A. add()<<",";

    cout<<"s2="<<B, add()<<end1;

    }

    写出该程序的运行结果:【 】。


    正确答案:s1=11s2=8.2
    s1=11,s2=8.2

  • 第2题:

    下列程序不能通过编译,应该在划线部分填写的语句是______。 include include

    下列程序不能通过编译,应该在划线部分填写的语句是______。

    include<iostream.h>

    include<stdlib.h>

    double Func(int a,int b,char ch)

    {

    double x;

    switch(ch)

    {

    case'+':

    x=double(a)+b;

    break;

    case '-':

    x=double(a)-b;

    break;

    case '*':

    x=double(a)*b;

    break;

    case'/':

    if(B)x=double(a)/b;

    else

    exit(1);

    break;

    default:

    exit(1);

    }

    ______

    }

    void main( )

    {

    cout<<Func(32,6,'-')<<",";

    cout<<Func(32,6, '*')<<",";

    cout<<Func(32,6,'/')<<endl;

    }


    正确答案:return x;
    return x; 解析:本题函数声明时指定了函数的返回值为double,因此在函数体中必须存在一个return语句。

  • 第3题:

    以下程序段运行后的输出结果为_____。 double x=5.16894; printf(“%fn“,(int)(x*10000+0.5)/(double)10000);

    A.5.169000

    B.5.175000

    C.5.168900

    D.5.168000


    42

  • 第4题:

    下列程序的运行结果是______。include int Func(int *a,int n) {int s=1; for(int i=0

    下列程序的运行结果是______。

    include<iomanip.h>

    int Func(int *a,int n)

    {int s=1;

    for(int i=0;i<n;i++)

    s*=*a++;

    returns;}

    void main()

    {inta[]:{1,2,3,4,5,6,7,8};

    intb=Func(a,6)+Func(&a[5],2);

    cout<<“b=“<(b<<endl;}


    正确答案:b=762。
    b=762。 解析: 本题考查了。a++的用法。*a++作为表达式时,先计算*a作为表达式的值,然后使指针变量 a本身增1,在本惠中,s*=*a++等同于3=s**a,a++,S后面第一个*是乘号。

  • 第5题:

    写出下面程序执行后的运行结果。 #include <stdio.h> #include <math.h> #define ROUND(x,m) ((int)((x)*pow(10,m)+0.5)/pow(10,m)) int main() { printf("%f,%f", ROUND(12.3456,1),ROUND(12.3456,2)); return 0; }


    100(10) < = > 64(16)