Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. #include <locale.h>
  5.  
  6. int main() {
  7.     setlocale(LC_ALL, "rus");
  8.     char s[50];  
  9.     printf(" \n Введите число -> ");
  10.     gets(s);
  11.     char *whole, *fract;
  12.     int length;
  13.     if (isdigit(*s) != 0) {
  14.         whole = strtok(s, ".");
  15.         printf("%s.", whole);
  16.         fract = strtok(NULL, ".");
  17.         printf("%s\n", fract);
  18.         length = strlen(fract);
  19.         if(length >= 7) {
  20.             printf("Введено число типа double\n");
  21.     } else {
  22.         printf("Введено число типа float\n");
  23.         }
  24.     }  
  25.     else {
  26.         printf("Введенная строка не является вещественным числом\n");
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement