Advertisement
Josif_tepe

Untitled

Dec 24th, 2020
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.32 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. //    fprintf(out, "Zdravo");
  36. //    if(f != NULL) { // toa znaci deka datotekata postoi
  37.         int k;
  38.         fscanf(f, "%d", &k);
  39.         char c;
  40.         fprintf(out, "%d\n", k);
  41.         c = fgetc(f); // getchar()
  42.         while((c = fgetc(f)) != EOF) { // EOF - end of file
  43.             if(e_samoglaska(c) == 1) {
  44.                 int brojac = k;
  45.                
  46.                 while(brojac > 0) {
  47.                     fprintf(out, "%c", c);
  48.                     brojac -= 1;
  49.                 }
  50.             }
  51.             else {
  52.                 fprintf(out, "%c", c);
  53.             }
  54.         }
  55.        
  56. //    }
  57.     rff();
  58.     return 0;
  59.    
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement