Advertisement
Guest User

Hui

a guest
Apr 10th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5. #include <string.h>
  6.  
  7. int main()
  8. {
  9.     system("chcp 1251 > null");
  10.     char s[1000];
  11.     char x[100][100];
  12.     char n;
  13.     int i;
  14.     printf("Введите строку\n");
  15.     gets_s(s);
  16.     for (int i = 0; i < 100; i++) // пустой массив
  17.     {
  18.         for (int j = 0; j < 100; j++)
  19.         {
  20.             x[i][j] = ' ';
  21.         }
  22.     }
  23.     int k = 0, kol = 0;
  24.     int l = 0;
  25.     for (int i = 0; i < strlen(s); i++)
  26.     {
  27.         if (s[i] != ' ') x[k][l++] = s[i];
  28.         else
  29.         {
  30.             k++;
  31.             l = 0;
  32.         }
  33.     }
  34.     for (int i = 0; i < strlen(s); i++)
  35.     {
  36.         for (int j = 0; j < strlen(s); j++)
  37.         {
  38.             if (x[i] == x[j] && x[i][j] != ' ') kol++;
  39.             if (x[i][j] != ' ') printf("%c", x[i][j]);
  40.         }
  41.         printf(" ");
  42.     }
  43.     printf("\n%d ", kol);
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement