Advertisement
MattDovi

Pb2

Nov 23rd, 2022 (edited)
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. #define MAX 300
  6. char vocale[20]={"aeiouAEIOU"};
  7. int main()
  8. {
  9.     FILE* fis;
  10.     FILE* out;
  11.     out=fopen("output.txt", "w");
  12.     char rand[MAX];
  13.     if (!(fis = fopen("fisier.txt", "r")))
  14.     {
  15.         perror("Eroare la deschidere, cu mesajul de eroare:");
  16.         exit(1);
  17.     }
  18.     while(!feof(fis))
  19.     {
  20.        if (!fgets(rand,100,fis))
  21.             {  exit(1);}
  22.         int nrvocale=0;
  23.         for(int i=0;i<strlen(rand);i++)
  24.             if(strchr(vocale, rand[i]))
  25.                 nrvocale++;
  26.         if(nrvocale != 0 && nrvocale % 2 == 0)
  27.             fprintf(out, "%s", rand);
  28.     }
  29.     fclose(fis);
  30.     fclose(out);
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement