Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- #include <mem.h>
- char analyze(char *pattern);
- int main( )
- {
- char pattern[256];
- printf("Podaj tekst: ");
- fflush(stdin);
- scanf("%[^\n]255s", pattern);
- analyze(pattern);
- }
- char analyze(char *pattern)
- {
- int possition;
- int NumberOfLetters = 0;
- char *ArrayOfWords = NULL;
- bool CanIWrite = false;
- for(possition = 0; possition < 256; possition++)
- {
- if(possition == 0)
- {
- if(pattern[possition] >= 48 && pattern[possition] <= 57)
- {
- CanIWrite = true;
- }
- }
- if(pattern[possition] >= 48 && pattern[possition] <= 57 && pattern[possition - 1] == 32)
- {
- CanIWrite = true;
- }
- if(pattern[possition] == 32)
- {
- CanIWrite = false;
- NumberOfLetters++;
- ArrayOfWords = (char*)realloc(ArrayOfWords,NumberOfLetters*sizeof(char));
- *(ArrayOfWords + NumberOfLetters - 1) = 32;
- }
- if(CanIWrite == true)
- {
- NumberOfLetters++;
- ArrayOfWords = (char*)realloc(ArrayOfWords,NumberOfLetters*sizeof(char));
- *(ArrayOfWords + NumberOfLetters - 1) = pattern[possition];
- }
- }
- for(possition = 0; possition < strlen(ArrayOfWords); possition++)
- {
- printf("%c", ArrayOfWords[possition]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement