-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfonctions.cpp
More file actions
75 lines (68 loc) · 1.51 KB
/
Copy pathfonctions.cpp
File metadata and controls
75 lines (68 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "fontions.h"
std::vector<long> listPiece;
std::string type;
void load_config(){
std::ifstream userParam("userConfig.txt");
if(userParam){
char t[500];
userParam.getline(t,500);
::type.append(t);
int a;
while (userParam >> a) {
listPiece.push_back(a);
}
}else{
reset_config();
}
}
void reset_config(){
std::ofstream userParam("userConfig.txt");
userParam << "Francfa"<<std::endl<<"1"<<std::endl<<"5"<<std::endl<<"10"<<std::endl<<"15"<<std::endl<<"25"<<std::endl<<"50"<<std::endl<<"100";
::listPiece.clear();
::type.clear();
userParam.close();
load_config();
}
std::string get_type(){
return ::type;
}
std::string to_str_p(){
int i = ::listPiece.size(), j =0;
std::string p;
while (j < i) {
p += std::string(" ") + to_str(listPiece[j]);
j++;
}
return p;
}
size_t num_piece(){
return ::listPiece.size();
}
long get_piece(size_t i){
return ::listPiece[i];
}
void set_piece(size_t i, long val){
::listPiece[i] = val;
}
long num_piece_of(long long &somme, long piece){
long nb = 0;
while (piece <= somme) {
nb++;
somme-= piece;
}
return nb;
}
long long convertion(const char * chaine)
{
unsigned i = 0;
long long nombre = 0;
while(chaine[i] != '\0'){
if( chaine[i] > 47 && chaine[i] < 59){
nombre = nombre*10 + chaine[i] - 48;
}else{
return -1;
}
i++;
}
return nombre ;
}