dimanche 27 décembre 2015

How can I write output result depending on two state of input

i am using if command to decide output from two input A,B as the table

 A   B   write_output
 0   0   1 1
>0   0   0 1
 0  >0   1 0
>0  >0   0 0

For example, if A>0 and B=0 then i will write the output value as 0 and 1. I am using if command to implement it. But it was not my expected table. Could you help me to fix it

This is my code

std::ofstream myfile;
myfile.open ("report.txt", std::ios::app);  
if(A==0 & B==0)
   myfile <<  1 << "\t" <<1<<'\n';
else if (A>0)
   myfile << 1 << "\t" <<0<<'\n';
else if (B>0)
   myfile << 1 << "\t" <<0<<'\n';
else
   myfile << 0 << "\t" <<0<<'\n';
myfile.close();

Aucun commentaire:

Enregistrer un commentaire