Advertisement
beckon

Untitled

May 25th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main() {
  6.     char *str;
  7.     str = (char*)calloc(100,sizeof(char));
  8.     fgets(str,100,stdin);
  9.     bool fl1 = false,fl2 = false;
  10.     int t1 = 0, t2 = 0;
  11.     for (int i = 0; i < strlen(str); i++) {
  12.         if (!fl1 && str[i] >= '0' && str[i] <= '9') {
  13.             fl1 = true; t1 = i;
  14.         }
  15.         if (str[i] == '.' && fl1) {
  16.             t2 = i;
  17.         }
  18.         if (fl1) {
  19.             t2 = i;
  20.         }
  21.         if (str[i] <= '0' && str[i] >= '9' && str[i] != '.') {
  22.             fl1 = false, fl2 = false;
  23.         }
  24.     }
  25.     for (int i = t1; i <= t2; i++) printf("%c",str[i]);
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement