void Indentation::readFile(ifstream &inp)
    {int i;
    inp.unsetf(ios::skipws); //include white space in read
        for(i=0;!inp.eof();i++)
        inp>>store[i];
        numofchar=i-1;
    }
Example #2
0
size_t sprawdz_baze(ifstream &baza_pytan){
    if( !baza_pytan.good() )  {cout << "bazaZla\n"; return -1;}
    baza_pytan.clear();
    baza_pytan.seekg(0, ios::beg);
    baza_pytan.unsetf(std::ios_base::skipws);
    size_t line_count = count(istream_iterator<char>(baza_pytan),istream_iterator<char>(), '\n');
    baza_pytan.clear();
    baza_pytan.seekg(0,ios::beg);
    return line_count;
}
void process(ifstream &icin, int type) //预处理一个标号为type_id的文档
{
    doc_count[type]++;
    map<int, int> count;
    int m = 0;
    char ch;
    string now="";
    icin.unsetf(ios::skipws);
    while (icin>>ch)
    {
        if (valid(ch)) now+=ch;
        else
        {
            if (now!="") insert(m, count, now);
            now="";
        }
    }
    if (now!="") insert(m, count, now);
    printf("%d ",type);
    for (map<int,int>::iterator it = count.begin(); it != count.end(); it++)
        printf(" %d:%lf", it->first, it->second*1.0/m);
    printf("\n");
}
Example #4
0
int main ()
{
    
  fOut.open ( "6assign.out", ios::out );
  if ( !fOut )
    {
      cerr << "Can't open file." << endl;
      exit (-1); // Stops program if can't open file 6assign.out
    }
   
  const int MAX_SIZE = 30;
  char inFileName[MAX_SIZE];
  
  const int MAX_INPUT_SIZE = 100;
  double a[MAX_INPUT_SIZE];
   
  cout << "Input file name(s) separated by one space: ";
  cin.get ( inFileName, MAX_SIZE );

  cout << "Data will be read from: " << inFileName << endl;
  
  // Get data from input file
  fIn.open ( inFileName, ios::in );  
  fIn.unsetf ( ios::skipws );

  if ( !fIn )
    {
      cerr << "Can't open input file." << endl;
      exit (-1);
    }
  
  

  

  // Print standard header information
  ShowHeader ( fOut );


  
  
  // Calls function that calculates mininum, maxinimum and averave values
  //MaxMinAve ( a, MAX_INPUT_SIZE );

  // Call function that will read in the arrray
  //readArray ( a, MAX_INPUT_SIZE )
  
  // Call findMin function for minimum value
  Min1 = findMin ( a, MAX_INPUT_SIZE );
  fOut << "The minimum is: " << Min1 << endl;
 
  // Call findMax function for maximum value
  Max1 = findMax ( a, MAX_INPUT_SIZE );
  fOut << "The maximum is: " << Max1 << endl;

  // Call calAve function for average value
  Ave1 = calAve ( a, MAX_INPUT_SIZE );
  fOut << "The average is: " << Ave1 << endl;

  // Call function that calculates the standard deviation
  stDev1 = CalStandDev ( a, MAX_INPUT_SIZE );
  fOut << "The standard deviation is: " << stDev1 << endl;
  

  // Close the input file
  fIn.close();
  
  // Close the output file
  fOut.close();



  return 0;

}