Advertisement
Josif_tepe

Untitled

Dec 24th, 2020
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.26 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define MAX 100
  4.  
  5.  
  6. //ne menuvaj!
  7. void wtf() {
  8.     FILE *f = fopen("sp.txt", "w");
  9.     char c;
  10.     while((c = getchar()) != EOF) {
  11.         fputc(c, f);
  12.     }
  13.     fclose(f);
  14. }
  15. void rff() {
  16.     FILE *f = fopen("output.txt", "r");
  17.     char c;
  18.     while((c = fgetc(f)) != EOF) {
  19.         putchar(c);
  20.     }
  21.     fclose(f);
  22. }
  23. int e_samoglaska(char c) {
  24.     if(c == 'A' || c == 'a' || c == 'E' || c == 'e' || c == 'I' || c == 'i' || c == 'O' || c == 'o' || c == 'U' || c == 'u') {
  25.         return 1;
  26.     }
  27.     return 0;
  28. }
  29.  
  30. int main() {
  31.     wtf();
  32.    
  33.     FILE *f = fopen("sp.txt", "r");
  34.     FILE *out = fopen("output.txt", "w");
  35.     if(f != NULL) { // toa znaci deka datotekata postoi
  36.         int k;
  37.         fscanf(f, "%d", &k);
  38.         char c;
  39.         c = fgetc(f); // getchar()
  40.         while((c = fgetc(f)) != EOF) { // EOF - end of file
  41.             if(e_samoglaska(c) == 1) {
  42.                 int brojac = k;
  43.                
  44.                 while(brojac > 0) {
  45.                     fprintf(out, "%c", c);
  46.                     brojac -= 1;
  47.                 }
  48.             }
  49.             else {
  50.                 fprintf(out, "%c", c);
  51.             }
  52.         }
  53.        
  54.     }
  55.     rff();
  56.     return 0;
  57.    
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement