Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdbool.h>
- #include <locale.h>
- int main()
- {
- setlocale(LC_ALL, "Russian");
- bool t = false;
- char lotr[] = "1234567890";
- printf("Введите число:");char str[100] = "";
- scanf("%s", str);
- for (int i = 0; i < strlen(str); i++)
- {
- if (strchr(lotr, str[i]) == NULL)
- {
- t = false;
- printf("Неправильное число");
- break;
- }
- else {
- if (i == 0 && str[i] == '0')
- {
- t = false;
- printf("Неправильное число");
- break;
- }
- else {
- t = true;
- }
- }
- }
- if (t) {
- printf("Правильное число");
- }
- getchar();
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment