c++的程序完善

来源:百度知道 编辑:UC知道 时间:2024/09/21 19:26:30
C++的题,呵呵,大家帮帮我做做,o(∩_∩)o...
viod main() {
base a;
a.init(68,55);
a.print();
}
测试结果:2*68-55=81
要求根据结果完善程序

#include<iostream>
using namespace std;

class base
{
public:
void init(int i, int j)
{
x = i;
y = j;
}
void print ()
{
cout << "2*" << x << "-" << y << "=" << 2 * x - y << endl;
}
private:
int x;
int y;
};

int main()
{
base a;
a.init (68, 55);
a.print();
return 0;
}

不明白要完善成什么样。。。

开玩笑

class base {
public:
int m,n;
void init(int m,n){this->m =m; this->n = n;}
void print()
{
cout << 2 << '*' << m << '-' << n << '=' << 2*m-n << endl;
}
}

很简单的,,自己做

class base
{
private:
int x,y;