Відповідь:
C++ code:
#include <iostream>
class Number{
private:
int a,b,c;
int d;
public:
Number();
Number(int,int,int,int);
Number(const Number&);
~Number() = default;
bool check();
void exp();
};
Number::Number(){
a = 0;
b = 0;
c = 0;
d = 0;
}
Number::Number(int a,int b,int c,int d){
this->a = a;
this->b = b;
this->c = c;
this->d = d;
Number::Number(const Number& object){
this->a = object.a;
this->b = object.b;
this->c = object.c;
this->d = object.d;
bool Number::check(){
return (c - d == b && b - d == a);
void Number::exp(){
if(this->check()){
int counter = 0,i = this->a;
std::cout << i << " ";
while(counter <= 15){
i += this->d;
counter++;
else{
std::cout << "This is not a progression" << std::endl;
int main(){
Number obj(4,12,20,8);
obj.exp();
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Відповідь:
C++ code:
#include <iostream>
class Number{
private:
int a,b,c;
int d;
public:
Number();
Number(int,int,int,int);
Number(const Number&);
~Number() = default;
bool check();
void exp();
};
Number::Number(){
a = 0;
b = 0;
c = 0;
d = 0;
}
Number::Number(int a,int b,int c,int d){
this->a = a;
this->b = b;
this->c = c;
this->d = d;
}
Number::Number(const Number& object){
this->a = object.a;
this->b = object.b;
this->c = object.c;
this->d = object.d;
}
bool Number::check(){
return (c - d == b && b - d == a);
}
void Number::exp(){
if(this->check()){
int counter = 0,i = this->a;
std::cout << i << " ";
while(counter <= 15){
i += this->d;
std::cout << i << " ";
counter++;
}
}
else{
std::cout << "This is not a progression" << std::endl;
}
}
int main(){
Number obj(4,12,20,8);
obj.exp();
return 0;
}
https://znanija.com/task/49751041