Advertisement
Pandarec13

protection of moron#1

Oct 12th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <cctype>   // для функции isdigit
  3. #include <locale.h>
  4. #include <string>
  5. int ggg(string);
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. setlocale(LC_ALL, "Russian");
  11.  
  12. string a;
  13. cout << "введите положительное целое число : ";
  14. cin >> a;
  15. ggg(a);
  16. while (ggg(a) != 0) {
  17. cin >> a;
  18. }
  19.  
  20. system("pause");
  21. return 0;
  22. }
  23. int ggg(string a) {
  24. int b;
  25. b = a.length();
  26. int k = 0;
  27. for (int i = 0; i < b; i++) {
  28.  
  29. if (isdigit(a[i])) continue;
  30. else {
  31. cout << "ошибка" << endl;
  32. k = 1;
  33. break;
  34. }
  35.  
  36. }
  37. return k;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement