Guest User

Untitled

a guest
Jun 9th, 2022
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.87 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdbool.h>
  4. #include <locale.h>
  5.  
  6. int main()
  7. {
  8.     setlocale(LC_ALL, "Russian");
  9.     bool t = false;
  10.     char lotr[] = "1234567890";
  11.     printf("Введите число:");char str[100] = "";
  12.     scanf("%s", str);
  13.     for (int i = 0; i < strlen(str); i++)
  14.     {
  15.         if (strchr(lotr, str[i]) == NULL)
  16.         {
  17.             t = false;
  18.             printf("Неправильное число");
  19.             break;
  20.         }
  21.         else {
  22.             if (i == 0 && str[i] == '0')
  23.             {
  24.                 t = false;
  25.                 printf("Неправильное число");
  26.                 break;
  27.             }
  28.             else {
  29.                 t = true;
  30.             }
  31.         }
  32.     }
  33.     if (t) {
  34.         printf("Правильное число");
  35.     }
  36.     getchar();
  37.     getchar();
  38. }
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment