Solutions
This commit is contained in:
parent
79b9099274
commit
d3aa42a3e0
64 changed files with 2726 additions and 0 deletions
40
sheet1/B/file_io.h
Normal file
40
sheet1/B/file_io.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef FILE_IO_H_INCLUDED
|
||||
#define FILE_IO_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
//using namespace std;
|
||||
|
||||
|
||||
/**
|
||||
This function opens the ASCII-file named @p file_name and reads the
|
||||
double data into the C++ vector @p v.
|
||||
If the file @p file_name does not exist then the code stops with an appropriate message.
|
||||
@param[in] file_name name of the ASCII-file
|
||||
@param[out] v C++ vector with double values
|
||||
*/
|
||||
|
||||
void read_vector_from_file(const std::string& file_name, std::vector<short>& v);
|
||||
|
||||
|
||||
/**
|
||||
This function opens the ASCII-file named @p file_name and rewrites its with the
|
||||
double data from the C++ vector @p v.
|
||||
If there are problems in opening/generating file @p file_name
|
||||
then the code stops with an appropriate message.
|
||||
@param[in] file_name name of the ASCII-file
|
||||
@param[in] v C++ vector with double values
|
||||
*/
|
||||
|
||||
void write_vector_to_file(const std::string& file_name, const std::vector<double>& v);
|
||||
|
||||
/**
|
||||
Fills the double-vector @p v with data from an input stream @p istr until this input stream
|
||||
ends regularily. The vector is cleared and its memory is automatically allocated.
|
||||
@param[in] istr input stream
|
||||
@param[out] v C++ vector with double values
|
||||
@warning An exception is thrown in case of wrong data format or corrupted data.
|
||||
*/
|
||||
void fill_vector(std::istream& istr, std::vector<double>& v);
|
||||
|
||||
#endif // FILE_IO_H_INCLUDED
|
||||
Loading…
Add table
Add a link
Reference in a new issue