Advertisement
ignatif

Untitled

Dec 1st, 2015
2,733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. using namespace std;
  4.  
  5. int main(){
  6.     int count = 0, checker = 0, floatingNumber = 0;
  7.     char ch, number[100];
  8.     printf("Insert text: \n");
  9.     while(ch != EOF){
  10.         ch = getchar();
  11.         if (isdigit(ch)){
  12.             number[count] = ch;
  13.             count +=1;
  14.             if (floatingNumber != 1) checker = 1;
  15.             continue;
  16.         }
  17.         if (ch == '.'){
  18.             floatingNumber = 1;
  19.             checker = 0;
  20.             continue;
  21.         }
  22.         if ((isspace(ch) || ch == ',' || isdigit(ch)) == 0){
  23.             if (checker == 1){
  24.                 printf("0");
  25.                 for (int i = 0; i < count; i++) {
  26.                     printf("%c", number[i]);
  27.                 }
  28.                 printf("\n");
  29.             }
  30.             checker = 0; count = 0; floatingNumber = 0;
  31.             continue;
  32.         }
  33.         if (ch == '\n') {
  34.             if (checker == 1){
  35.                 printf("0");
  36.                 for (int i = 0; i < count; i++) {
  37.                     printf("%c", number[i]);
  38.                 }
  39.                 printf("\n");
  40.             }
  41.             checker = 0; count = 0; floatingNumber = 0;
  42.            
  43.         }
  44.     }
  45.    return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement