当前位置:   article > 正文

python编写函数计算整数n的因子之和_请编写一个函数fun(),它的功能是计算并输出给定整数n的所有因子(不包括1与自身)之和(规定n的值不...

编写一个函数fun,功能是计算给定整数n的所有因子(不包括1和自身)之和,和值通过指

使用VC6打开考生文件夹下的工程RevProj14。此工程包含一个源程序文件RevMain14.cpp,但该程序中类的定义有错误。请改正程序中的错误,使它能得到正确结果。

注意,不要改动main函数,不得删行或增行,也不得更改程序的结构。

源程序文件RevMain14.cpp中的程序清单如下:

//RevMain14.cpp

include<iostream>

include<math>

using namespace std;

class Point

{

private:

double x;

double y;

public:

Point(){}

void Point(double x1,double y1)

{

x=x1;

y=y1;

}

void setvalue(double x,double y)

{

x=x;

y=y;

}

double getx ()

{

return x;

}

double gety()

}

return y;

}

void print()

{

cout<<"x="<<x<<",y= "<<y<<end1;

}

~Point(){}

};

class Line

{

private:

Point p1;

Point p2;

double width;

public:

Line(double x1,double y1,double x2,double y2,double d)

:p1(x1,y1),p2(x2,y2)

{

width=d;

}

~Line(){}

void displength()

{

double 1;

1=sqrt((p1.getx{)-p2.getx())*(p1.getx()-p2-getx())+

(p1.gety()-p2.gety())*(p1.gety()-p2.gety()));

cout<<"the length of Line is "<<1<<end1;

}

};

int main()

{

Line *p1;

Line 1(5,15,25,35,0.5);

p1=&1;

p1->displength();

return 0;

}

请帮忙给出正确答案和分析,谢谢!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/252398
推荐阅读
相关标签
  

闽ICP备14008679号