Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- char str[9*30];
- char *s = str;
- bool eof = false;
- int word_count = 0;
- char *words[30];
- int words_in[30];
- while(!eof)
- {
- char *word = s;
- *s = getchar();
- while(*s != ',' && *s != '.') {
- s++;
- *s = getchar();
- }
- if (*s == '.')
- eof = true;
- *s = 0;
- bool stored = false;
- for( int i = 0; i < word_count && !stored; i++ ){
- if( !strcmp( words[i], word ) ) {
- stored = true;
- words_in[i]++;
- }
- }
- if( !stored ) {
- words[word_count] = word;
- words_in[word_count] = 1;
- word_count++;
- }
- s++;
- }
- for( int i = 0; i < word_count; i++ ) {
- printf("%s %d\n", words[i], words_in[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement