Bob103

чекни

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