Bob103

строки римская 4

Dec 22nd, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main()
  5. {
  6. string s;
  7. getline(cin, s);
  8. int cnt = 0;
  9. for (int i = 0; i < int(s.size()); i++)
  10. {
  11. if (s[i] == '.')
  12. {
  13. cnt++;
  14. }
  15. else if (!isdigit(s[i]))
  16. {
  17. cout << "Bad string" << endl;
  18. return 0;
  19. }
  20. }
  21. if (cnt > 1)
  22. {
  23. cout << "Bad string: too many dots" << endl;
  24. return 0;
  25. }
  26. cout<<"It seems that string is good :-)" << endl;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment