Advertisement
fqrmix

Люба 4 лаба

Dec 11th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string.h>
  4. int kol(char *mas1, char *mas2, int n, int flag);
  5. void zap(char *mas1, char *mas2, char *mas3, int n, int flag);
  6. void vivod(char *mas, int a);
  7. int main()
  8. {
  9.     char S1[100];
  10.     char S2[100];
  11.     gets_s(S1);
  12.     gets_s(S2);
  13.     int z = strlen(S1);
  14.     int y = strlen(S2);
  15.     int x = kol(S1, S2, z, y);
  16.     char *S3 = (char*)malloc(x * sizeof(char));
  17.     zap(S1, S2, S3, z, y);
  18.     vivod(S3, x);
  19.     system("pause");
  20.     return 0;
  21. }
  22. int kol(char *mas1, char *mas2, int n, int flag)
  23. {
  24.     int s = 0, k = 0;
  25.     for (int i = 0; i < n; i++)
  26.     {
  27.         k = 0;
  28.         for (int j = 0; j < flag; j++)
  29.         if (mas1[i] != mas2[j])
  30.             k++;
  31.         if (k == flag)
  32.             s++;
  33.     }
  34.     return s;
  35. }
  36.  
  37. void zap(char *mas1, char *mas2, char *mas3, int n, int flag)
  38. {
  39.     int s = 0, k = 0;
  40.     for (int i = 0; i < n; i++)
  41.     {
  42.         k = 0;
  43.         for (int j = 0; j < flag; j++)
  44.             if (mas1[i] != mas2[j])
  45.                 k++;
  46.         if (k == flag)
  47.         {
  48.             mas3[s] = mas1[i];
  49.             s++;
  50.         }
  51.     }
  52. }
  53. void vivod(char *mas, int a)
  54. {
  55.  
  56.     for (int i = 0; i < a; i++)
  57.         printf("%c ", mas[i]);
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement