haha i've done it! i've finished the whole stupid problem...and on such short notice too (sarcastic)
ok the problem asked me to see wether the binary number from "nrbinar.in" was odd or not, and if the number was straight then, considering that number written as 2^x *odd number, i was supposed to find out the "x". (ie: 12, not being odd, can be written as 2^2 * 3 and in binary if you take away the two zeros from 1100(=12 in decimal) then you're left off with an odd number, namely 11(=3 in decimal), so the number of zeros you take away to form the bigest odd number possible is exactly the power of two i had to find.
[i know it took me a while...]
here's the final thing
Code:
#include <fstream.h>
#include <conio.h>
unsigned long int nr=0;
char a,t;
char paritate(){
fstream f("nrbinar.in", ios::in);
while(f>>t);
return t;
}
void main(){int c=0;
if(paritate()=='1')
cout<<"the number is odd";
else{fstream f("nrbinar.in", ios::in);
while(f>>a){
if(a=='1') nr=0, c=1;
if(a=='0') nr++; }
if(c==0)
cout<<"there is no power for wich, dividing our number by 2^it, will result an odd number";
else
cout<<"the number is straight, and the power of two sought is "<<nr;
}
getch();
}
oh one last question ... i was thinking the declaration of the f file was redundant in both "paritate" and "main", and, so, tryed to declare the file as a general variable ..along with the other variables general one like t...but the program didn't work. it couted something out of place.i forgot what. maybe i didn't declare the file right ...hmmm