-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc.cpp
More file actions
32 lines (26 loc) · 664 Bytes
/
misc.cpp
File metadata and controls
32 lines (26 loc) · 664 Bytes
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
//
// Created by Nicolas Tsagarides on 4/19/15.
//
#include "misc.h"
#include <iostream>
#include "global.h"
#include <regex>
std::string userInput()
{
std::string input;
getline(std::cin, input);
return (input);
}
bool is_number(const std::string& s) // checks if a string is numeric
{
return !s.empty() && std::find_if(s.begin(), s.end(), [](char c) { return !std::isdigit(c); }) == s.end();
}
bool is_double(const std::string &s)
{
std::regex rr("((\\+|-)?[[:digit:]]+)(\\.(([[:digit:]]+)?))?");
return (std::regex_match(s, rr));
}
bool compareXOfPoints(Point point1, Point point2)
{
return point1.getX() < point2.getX();
}