Advertisement
Josif_tepe

Untitled

Jun 12th, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.39 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4. #include <math.h>
  5.  
  6.  
  7. int main(int argc, char *argv[]) {
  8.     FILE *i1 = fopen(argv[1], "r");
  9.     FILE *i2 = fopen(argv[2], "r");
  10.     FILE *o = fopen(argv[3], "w");
  11.    
  12.     if(i1 == NULL || i2 == NULL) {
  13.         printf("GRESHKA");
  14.         return 0;
  15.     }
  16.     int bukvi1[26], bukvi2[26];
  17.     char niza1[1001], niza2[1001];
  18.     while(fgets(niza1, 500, i1)) {
  19.         fgets(niza2, 500, i2);
  20.         for(int i = 0; i < 26; i++) {
  21.             bukvi1[i] = 0;
  22.             bukvi2[i] = 0;
  23.         }
  24.         for(int i = 0; i < strlen(niza1); i++) {
  25.             if(isalpha(niza1[i])) {
  26.                 niza1[i] = tolower(niza1[i]);
  27.                 bukvi1[niza1[i] - 'a'] = 1;
  28.             }
  29.         }
  30.         for(int i = 0; i < strlen(niza2); i++) {
  31.             if(isalpha(niza2[i])) {
  32.                 niza2[i] = tolower(niza2[i]);
  33.                 bukvi2[niza2[i] - 'a'] = 1;
  34.             }
  35.         }
  36.         for(int i = 0; i < 26; i++) {
  37.             if(bukvi1[i] == 1 && bukvi2[i] == 1) {
  38.                 fprintf(o, "%c,", (char)(i + 'a'));
  39.             }
  40.         }
  41.         fprintf(o, "\n");
  42.     }
  43.     fclose(o);
  44.     FILE *i3 = fopen(argv[3], "r");
  45.     while(fgets(niza1, 500, i3)) {
  46.         printf("%s\n", niza1);
  47.     }
  48.     return 0;
  49. }
  50. /*
  51.  
  52.  in contrast
  53.  removed from the definition, a phenomenon known as the AI
  54.  1 7
  55.  **/
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement