I wrote the following code for a math problem and it won't write into the output file "coada2.out".
#include <iostream>
#include <fstream>
using namespace std;
int main() {
int sum = 0, x, y, z;
ifstream file_in("coada2.in");
file_in >> x >> y >> z;
file_in.close();
ofstream file_out;
file_out.open ("coada2.out");
sum=x+2;
if((y+1 || z+1) == sum) {
file_out << sum;
file_out.close();
}
else{
cout<<"-1";
}
return 0;
}
if((y+1 || z+1) == sum) {is quite strange to me. It will not do what you want.zandyare both-1andxis-2. In that case (-1+1 || -1 +1 ) will be false and this false which will equal sum because its 0.