tikky7
BAN USERActually sorry like this instead
void Divide(int dividend, int divisor, int* answer, int* remainder)
{
if( divisor != 0)
{
int neg=1;
if (dividend<0 || divisor<0) neg=-1;
dividend = abs(dividend);
divisor= abs(divisor);
int i=0;
*remainder=dividend%divisor;
while( dividend>*remainder )
{
dividend=dividend-divisor;
i++;
}
*answer=i*neg;
}
else
{
*answer=NULL;
*remainder=NULL;
}
}
int main()
{
int a=11;
int b=5;
int ans=NULL;
int rem=NULL;
Divide(a,b,&ans,&rem);
if (ans != NULL || rem != NULL)
cout << "Ans= " << ans << " Rem= " << rem <<endl;
}
How about using modulus and the multiple subtractions instead
void(int dividend, int divisor, int* answer, int* remainder)
{
if( divisor != 0)
{
negate=1;
if (dividend<0 || divisor<0) negate=-1;
dividend = abs(dividend);
divisor= abs(divisor);
int i=0
temp=std::numeric_limits<int>::max();
remainder=dividend%divisor;
while( temp>remainder )
{
temp=dividend-divisor;
i++;
}
answer=i*negate;
}
else
{
}
By file contents do you mean sorting the stuff inside the file? If so then:
- tikky7 April 30, 2015make not to run this on binary file or executable files by typing:
file <filename>
cat <filename> | sort <some options for your sort> | tee <someOtherFile>