jetbrains rider, is there a way to make my code smaller?
Answered
see my program?
#include <iostream>
using namespace std;
int main()
{
double NumberPi = 3.14159;
double NumberE = 2.718281828;
int count = 0;
bool Condition = true;
do
{
cout << "The number Pi is: " << NumberPi << endl;
cout << "The number E is: " << NumberE << endl;
cout << "The number count is: " << count << endl;
cout << "Pi + E * count = " << NumberPi + NumberE * count << endl;
count++;
if (count <= 100)
{
Condition = true;
}
else
{
Condition = false;
}
}while(Condition);
system("pause");
}
I want to know if there is a plugin or way to make the code smarter/cleaner.
this is what I want it to do:
#include <iostream>
using namespace std;
int main()
{
double NumberPi = 3.14159;
double NumberE = 2.718281828;
int count = 0;
bool Condition = true;
do
{
cout << "The number Pi is: " << NumberPi << endl;
cout << "The number E is: " << NumberE << endl;
cout << "The number count is: " << count << endl;
cout << "Pi + E * count = " << NumberPi + NumberE * count << endl;
count++;
if (count > 100)
{
Condition = false;
}
}while(Condition);
system("pause");
}
Please sign in to leave a comment.
Please try with the refactoring rules for the
if
statements.i select the code :
and rick click the code and select “Refactor this”, and it says “refactor this: extract method”. then it generates this code:
Structure-based refactoring/inspection couldn't solve operation flow issues. Utilizing AI Assistant for suggesting refactoring can offer an improved solution. In AI Actions | Suggest Refactoring, it provides a better way to handle the operation flow :
For comprehensive C++ development, CLion offers a better experience. Rider provides C++ support for Unreal Engine projects only.