d06 ex00 all checks are ok
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user