Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- using namespace std;
- int main(){
- int count = 0, numberExists = 0, floatingNumber = 0;
- char ch, number[100];
- printf("Insert text: ");
- while(ch != EOF){
- ch = getchar();
- if (isdigit(ch)){
- number[count] = ch;
- count +=1;
- if (floatingNumber != 1) numberExists = 1;
- continue;
- }
- if (isspace(ch) || ch == ','){
- if (numberExists == 1){
- printf("0");
- for (int i = 0; i < count; i++) {
- printf("%c", number[i]);
- }
- printf("\n");
- }
- numberExists = 0; count = 0; floatingNumber = 0;
- continue;
- }
- if (isdigit(ch) == 0){
- floatingNumber = 1;
- numberExists = 0;
- count = 0;
- continue;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement