d06 ex00 all checks are ok

This commit is contained in:
hugogogo
2022-03-07 22:30:41 +01:00
parent 142687283e
commit 4ee3ae3e7d
10 changed files with 234 additions and 73 deletions

View File

@@ -1,16 +1,26 @@
#include <iostream>
#include <string>
#include <cctype> // isdigit()
#include "color.h"
#include "convert.h"
//Char toInt(str) {
//
//}
bool isInt(std::string str) {
if (str.length() == 2)
std::string int_xtrem = MAX_INT;
if (str[0] == '-')
int_xtrem = MAX_INT_1;
if (str[0] == '+' || str[0] == '-')
str.erase(str.begin());
if (str.length() == 0 || str.length() > INT_MAX_LENGTH)
return false;
if (str.find_first_not_of("0123456789") != std::string::npos)
return false;
if (str.length() < INT_MAX_LENGTH)
return true;
return false;
if (str.compare(int_xtrem) > 0)
return false;
return true;
}
bool checkInt(std::string str) {