I have no clue whats wrong here but the code doesn't put out anything
this might be something really basic that i overlooked
the "cout << TenQuintillion" was a test to see if it was a problem further down
#include <iostream>
usingnamespace std;
int main() {
int OutCount;
double SideA = 3;
double SideB = 4;
double A;
double B;
double TotalA;
double TotalB;
double TenQuintillion;
TenQuintillion = 10 * 1000 * 1000 * 1000 * 1000 * 1000;
cout << TenQuintillion;
while (SideB < 101) {
while (TotalB < TenQuintillion) {
TotalA = A / 2 * ((SideA - 2) * A - (SideA - 4));
TotalB = B / 2 * ((SideB - 2) * B - (SideB - 4));
if (TotalA > TotalB) {
B = B + 1;
}
elseif (TotalA == TotalB) {
A = A + 1;
B = B + 1;
cout << TotalA << " ";
if (OutCount % 10 == 0) {
cout << "\n";
}
}
else {
A = A + 1;
}
}
OutCount = 0;
cout << "\n\n\n";
if (SideB < 100) {
SideB = SideB + 1;
}
else {
SideA = SideA = 1;
SideB = SideA = 1;
}
}
return 0;
}
after a bit of messing around i found out that without the while loops the code gives an output however the answer is far off even using long long variables
I think the problem is totalA == totalB. Comparison between doubles is not reliable. Try doing if(floor(totalA) == floor(totalB)) for which you will need <cmath>
floor(n) rounds a double (or float) down to the nearest integer.
wait Gkneeus you get output?
in the command prompt window i get it does absolutely nothing
also i did initialize all variables and that didn't help
the loop will finish when SideA = 100
and i tried starting with A and B at 1 which still didnt do anything
i made a new file and rewrote the code and it worked
although in the first edition i forgot to put A, B TotalA, and TotalB = 0 after the end of the inner loop
i think the first file must have glitched because the second one worked just fine
ran the file with fstream and noticed i forgot to exclude divisible side lengths resulting in a 1.2 GB text file (which notepad can't open) and i didn't even let the process play through more than a hundredth of the way