Advertisement
Zennoma

My_vse_perezhivaem_za_tebya

Dec 9th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <windows.h>
  4.  
  5.  
  6.  
  7. void Test( int &l, int &q, int &h, char s[], char letters[], char numbers[], char symbols[], char* waste)
  8. {
  9.    
  10.     if (*waste >= 48 && *waste <= 57)
  11.     {
  12.         numbers[l] = *waste;
  13.         l++;
  14.     }
  15.     else
  16.     {
  17.         if ((*waste >= 65 && *waste <= 90) || (*waste >= 97 && *waste <= 122))
  18.         {
  19.             letters[h] = *waste;
  20.             h++;
  21.         }
  22.         else
  23.         {
  24.             symbols[q] = *waste;
  25.             q++;
  26.         }
  27.     }
  28. }
  29.  
  30. void main()
  31. {
  32.     SetConsoleCP(1251);
  33.     SetConsoleOutputCP(1251);
  34.     int n;
  35.     printf("Input a size of your string:\n");
  36.     scanf_s("%d", &n);
  37.  
  38.     char* s, * letters, * numbers, * symbols,waste;
  39.  
  40.     s = new char[n];
  41.     letters = new char[n];
  42.     numbers = new char[n];
  43.     symbols = new char[n];
  44.  
  45.     char sign;
  46.     int i = 0;
  47.     printf("Input your string\n(the size shouldn't be bigger then %d):\n", n);
  48.     int l = 0, h = 0, q = 0;
  49.     for (int i = 0; i < n*2; i++)
  50.     {
  51.         scanf_s("%c", &sign);
  52.         waste = sign;
  53.         Test(l, q, h, s, letters, numbers, symbols, &waste);
  54.     }
  55.  
  56.     int mark;
  57.     puts("What do you want to see?\n1)Only letters\n2)Only numbers\n3)Only symbols\n");
  58.     scanf_s("%d", &mark);
  59.     if (mark == 1)
  60.     {
  61.         for (int f = 0; f < h; f++)
  62.         {
  63.             printf("%c ", letters[f]);
  64.         }
  65.     }
  66.     else
  67.     {
  68.         if (mark == 2)
  69.         {
  70.             for (int f = 0; f < l; f++)
  71.             {
  72.                 printf("%c", numbers[f]);
  73.             }
  74.  
  75.         }
  76.         else
  77.         {
  78.             for (int f = 0; f < q; f++)
  79.             {
  80.                 printf("%2c", symbols[f]);
  81.             }
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement