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, checker = 0, floatingNumber = 0;
- char ch, number[100];
- printf("Insert text: \n");
- while(ch != EOF){
- ch = getchar();
- if (isdigit(ch)){
- number[count] = ch;
- count +=1;
- if (floatingNumber != 1) checker = 1;
- continue;
- }
- if (ch == '.'){
- floatingNumber = 1;
- checker = 0;
- continue;
- }
- if ((isspace(ch) || ch == ',' || isdigit(ch)) == 0){
- if (checker == 1){
- printf("0");
- for (int i = 0; i < count; i++) {
- printf("%c", number[i]);
- }
- printf("\n");
- }
- checker = 0; count = 0; floatingNumber = 0;
- continue;
- }
- if (ch == '\n') {
- if (checker == 1){
- printf("0");
- for (int i = 0; i < count; i++) {
- printf("%c", number[i]);
- }
- printf("\n");
- }
- checker = 0; count = 0; floatingNumber = 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement