-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.cpp
More file actions
56 lines (52 loc) · 1.14 KB
/
util.cpp
File metadata and controls
56 lines (52 loc) · 1.14 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
#include <type.h>
void pause(){
cout <<"Press any key to continue! \n" ;
getch();
}
int getInt (string promt, int min, int max){
int num;string s;
do {
cout << promt;
getline(cin,s);
num = atoi(s.c_str());
}while(num<min || num>max);
return num;
}
float getFloat (string promt, float min, float max){
float num;string s;
do {
cout << promt;
getline(cin,s);
num = atoi(s.c_str());
}while(num<min || num>max);
return num;
}
char *getStr (string promt){
cout << promt;
string s;
getline(cin,s);
char *cStr = new char[s.length() +1];
strcpy(cStr,s.c_str());
return cStr;
}
string IntToString(int a){
string temp;
int i = 0;
while (a != 0){
int b = a/10;
int c = a - b*10;
a /= 10;
char s = 48+c;
temp += s;
i++;
}
for (int i = 0, j = temp.size()-1; i < temp.size()-1; i++, j--){
char s = temp[i];
temp[i] = temp[j];
temp[j] = s;
if (i-j == 0){
break;
}
}
return temp;
}