Advertisement
Guest User

Untitled

a guest
Jun 5th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <regex>
  4.  
  5. using namespace std;
  6. #define DOT "."
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10. int number;
  11. string value;
  12. cout << "Zadejte číslo: ";
  13. cin >> value;
  14.  
  15. cout << "Hodnota je: " << value << DOT << endl;
  16.  
  17. regex reg("^[0-9]+$");
  18.  
  19. if(regex_match(value, reg))
  20. {
  21. number = atoi(value.c_str());
  22. cout << "Zadané číslo je " << number << DOT << endl;
  23. }else cout << "Hodnota musí být číslo" << DOT << endl;
  24.  
  25. system("PAUSE");
  26. return EXIT_SUCCESS;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement