Advertisement
ignatif

Untitled

Dec 5th, 2015
622
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 <ctype.h>
  3. using namespace std;
  4.  
  5. int main(){
  6.     int count = 0, numberExists = 0, floatingNumber = 0;
  7.     char ch, number[100];
  8.     printf("Insert text: ");
  9.     while(ch != EOF){
  10.         ch = getchar();
  11.         if (isdigit(ch)){
  12.             number[count] = ch;
  13.             count +=1;
  14.             if (floatingNumber != 1) numberExists = 1;
  15.             continue;
  16.         }
  17.  
  18.         if (isspace(ch) || ch == ','){
  19.             if (numberExists == 1){
  20.                 printf("0");
  21.                 for (int i = 0; i < count; i++) {
  22.                     printf("%c", number[i]);
  23.                 }
  24.                 printf("\n");
  25.             }
  26.             numberExists = 0; count = 0; floatingNumber = 0;
  27.             continue;
  28.         }
  29.  
  30.         if (isdigit(ch) == 0){
  31.             floatingNumber = 1;
  32.             numberExists = 0;
  33.             count = 0;
  34.             continue;
  35.         }
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement