0
What is wrong with the second “if “ part ?
#include <iostream> using namespace std; int main() { int a, b, c, d, r, s, n; cin >> n; while (cin >>a>>b>>c>>d){ s=b-a; r=b/a; if ( b==s+a && c==s+b && d==s+c) cout << a <<" "<< b <<" "<< c <<" "<< d << " " << d+s <<endl; if( b==a*r && c==b*r && d==c*r) cout << a << " "<<b << " "<< c << " "<< d << " "<< d*r <<endl; } return 0; }
1 ответ
+ 1
You must write what is wrong.
C++ code is valid.
The second if checks whether the entered data are elements of geometric progression.