Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
CyclicExpression Checker
//g++ 7.4.0 //cyclical expression checker //created by Rezaul Hoque on December 2, 2020; //contact at : jewelmrh@yahoo.com //a program to check if an equation is cyclical that means in a 3-variable equation if the 1st replaces the 2nd, the 2nd replaces the 3rd and the 3rd replaces the 1st variable then the result of the equation stays the same. // read the input , three variables, from the user; // here we are dealing with three equations; so two results are needed for each equation; one result is for the original equation and the other one for the altered equation; // compare the results; if the results are the same then we can confidently conclude the equation is cyclical. #include <iostream> using namespace std; int main () { float a, b,c, res1, res2,res3,res4,res5,res6; cout<<"Equations are:\n"; cout <<"(1) a*a + b*b+ c*c+ a*c+ b*c+ c*a\n"; cout<<"(2) a*a - b*b+ c*c\n"; cout <<"(3) a/b+ b/c + c/a\n"; cout<<endl; res1=a*a + b*b+ c*c+ a*c+ b*c+ c*a; res2=b*b+ c*c+ a*a+b*c+c*a+ a*c; res3 = a*a - b*b+ c*c; res4= b*b- c*c+a*a; res5= a/b+ b/c + c/a; res6= b/c + c/a + a/b; cout <<" Enter three integers : \n"; cin>>a>>b>>c; if(res1==res2) cout<<" a*a + b*b+ c*c+ a*c+ b*c+ c*a is cyclical.\n"; else cout<<" a*a + b*b+ c*c+ a*c+ b*c+ c*a is not cyclical.\n"; if(res3==res4) cout<<"a*a - b*b+ c*c is cyclical.\n"; else cout<<"a*a - b*b+ c*c is not cyclical.\n"; if(res5==res6) cout<<"a/b+ b/c + c/a is cyclical.\n"; else cout<<"a/b+ b/c + c/a is not cyclical.\n"; return 0; }
run
|
edit
|
history
|
help
0
danger73
HI
string probe
WeekD
C++ Car Racing game framework 2
Shortest Non Common Subsequence
задача new
binder
Matrix Multiplication Using Threads
ProdPriceEnum