void BigInt::WriteToFile(const char* fileName)
{
    ofstream ofst(fileName);

    if (this->sign == -1)
    {
        ofst << "-";
    }

    ofst << number[number.size() - 1];

    for (int i = number.size() - 2; i >= 0; i--)
    {
        if (number[i] < (BigInt::base / 10))
        {
            int count = 0;
            int buf = number[i];

            if (number[i] == 0) count += 1;

            while (buf){
                buf /= 10;
                count++;
            }
            for (int j = 0; j < (BigInt::baseLen - count); j++)
            {
                ofst << 0;
            }
        }
        ofst << number[i];
    }
}
示例#2
0
文件: bint.cpp 项目: ZedXan/Schnorr
void bint::write(string str, char* c)
{
	ofstream ofst(c);

	ofst << str;

	ofst.close();
}
示例#3
0
int run ( ucam::util::RegistryPO const& rg) {
  ucam::util::PatternAddress<unsigned> input (rg.get<std::string>
      (HifstConstants::kInput) );
  ucam::util::PatternAddress<unsigned> output (rg.get<std::string>
      (HifstConstants::kOutput) );
  WeightFunctorT mwcopy;
  for ( ucam::util::IntRangePtr ir (ucam::util::IntRangeFactory ( rg,
                                    HifstConstants::kRangeOne ) );
        !ir->done();
        ir->next() ) {
    FORCELINFO ("Processing file " << input ( ir->get() ) );
    boost::scoped_ptr< fst::VectorFst<ArcT> > ifst (fst::VectorFstRead<ArcT>
        ( input (
            ir->get() ) ) );
    boost::scoped_ptr< fst::VectorFst<Arc2T> > ofst (new fst::VectorFst<Arc2T>);
    Map ( *ifst, &*ofst, MapperT ( mwcopy ) );
    fst::FstWrite<Arc2T> ( *ofst, output (ir->get() ) );
  }
};