TP7
This commit is contained in:
37
TP7/getio.cpp
Normal file
37
TP7/getio.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "getio.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void getfloat(ifstream& s, float& f, const char sep) {
|
||||
string tmp;
|
||||
|
||||
getline(s, tmp, sep);
|
||||
|
||||
if (tmp == "N/R" || tmp.empty())
|
||||
return;
|
||||
|
||||
tmp.erase(remove(tmp.begin(), tmp.end(), '.'), tmp.end());
|
||||
|
||||
auto it = tmp.begin();
|
||||
while (it != tmp.end() && *it != ',')
|
||||
it++;
|
||||
if (it != tmp.end()) {
|
||||
*it = '.';
|
||||
}
|
||||
|
||||
f = stof(tmp);
|
||||
}
|
||||
|
||||
void getint(ifstream& s, int& f, const char sep) {
|
||||
string tmp;
|
||||
|
||||
getline(s, tmp, sep);
|
||||
|
||||
if (tmp == "N/R" || tmp.empty())
|
||||
return;
|
||||
|
||||
f = stoi(tmp);
|
||||
}
|
||||
Reference in New Issue
Block a user