Pandarec13

protection of moron#2

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