Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <windows.h>
- void Test( int &l, int &q, int &h, char s[], char letters[], char numbers[], char symbols[], char* waste)
- {
- if (*waste >= 48 && *waste <= 57)
- {
- numbers[l] = *waste;
- l++;
- }
- else
- {
- if ((*waste >= 65 && *waste <= 90) || (*waste >= 97 && *waste <= 122))
- {
- letters[h] = *waste;
- h++;
- }
- else
- {
- symbols[q] = *waste;
- q++;
- }
- }
- }
- void main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int n;
- printf("Input a size of your string:\n");
- scanf_s("%d", &n);
- char* s, * letters, * numbers, * symbols,waste;
- s = new char[n];
- letters = new char[n];
- numbers = new char[n];
- symbols = new char[n];
- char sign;
- int i = 0;
- printf("Input your string\n(the size shouldn't be bigger then %d):\n", n);
- int l = 0, h = 0, q = 0;
- for (int i = 0; i < n*2; i++)
- {
- scanf_s("%c", &sign);
- waste = sign;
- Test(l, q, h, s, letters, numbers, symbols, &waste);
- }
- int mark;
- puts("What do you want to see?\n1)Only letters\n2)Only numbers\n3)Only symbols\n");
- scanf_s("%d", &mark);
- if (mark == 1)
- {
- for (int f = 0; f < h; f++)
- {
- printf("%c ", letters[f]);
- }
- }
- else
- {
- if (mark == 2)
- {
- for (int f = 0; f < l; f++)
- {
- printf("%c", numbers[f]);
- }
- }
- else
- {
- for (int f = 0; f < q; f++)
- {
- printf("%2c", symbols[f]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement