Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <Windows.h>
- #include <stdlib.h>
- #include <malloc.h>
- #include <string.h>
- #include <locale.h>
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int i = 0;
- char c;
- int* a;
- a = (int*)malloc(sizeof(int));
- a[0] = 0;
- int n = 0;
- char s[60] = "";
- while ((c = getchar()) != '.' && i <= 60 && c != '\n')
- {
- if (c != ' ')
- {
- s[i] = c;
- i++;
- }
- else
- {
- int flag = 0;
- for (int j = 0; j < n; j++)
- {
- if (a[j] == i) flag = 1;
- }
- if (flag == 0)
- {
- a = (int*)realloc(a, sizeof(a) + sizeof(int));
- a[n] = i;
- n++;
- }
- }
- }
- a = (int*)realloc(a, sizeof(a) + sizeof(int));
- a[n] = i;
- printf("\nYour line: %s", s);
- printf("\n");
- for (int i = 0; i <= n; i++) printf("%d\t", a[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement