Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- #define MAX 1000
- /*
- Дадена е текстуална датотека text.txt.
- Да се избројат и испечатат сите последнователни појавувања на соседни самогласки во датотеката. Појавата на големи и мали букви да се игнорира. Пронајдените парови самогласки да се испечатат на екран, секој во нов ред со мали букви. Потоа во нов ред се печати бројот на појавувања на паровите самогласки.
- Пример: за датотеката:
- IO is short for Input Output
- medioio medIo song
- излез:
- io
- ou
- io
- oi
- io
- io
- 6
- For example:
- Input Result
- Why so serious? io
- # ou
- 2
- */
- void writeToFile() {
- FILE *f = fopen("text.txt", "w");
- char c;
- while((c = getchar()) != '#') {
- fputc(c, f);
- }
- fclose(f);
- }
- int main() {
- writeToFile();
- FILE *dat;
- if ((dat=fopen("text.txt","r"))==NULL){
- fprintf(stderr,"ERROR DURING OPENING");
- return -1;
- }
- char niza[MAX];
- char c;
- int isvowel=0;
- char prev;
- int cnt=0;
- while((c=fgetc(dat)) != EOF){
- if (tolower(c) == 'a' || tolower(c) == 'e' || tolower(c) == 'i' || tolower(c) == 'i' || tolower(c) == 'o' || tolower(c) == 'u'){
- if (isvowel == 1){
- printf("%c%c\n",tolower(prev),tolower(c));
- prev = c;
- cnt++;
- }
- else{
- isvowel=1;
- prev = c;
- }
- }
- else{
- isvowel =0;
- }
- }
- printf("%d",cnt);
- return 0;
- }
Add Comment
Please, Sign In to add comment