Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.22 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #define LINE 1024
  6.  
  7. void create(void);
  8. void check(char *);
  9. void processing(void);
  10. void out(void);
  11. struct text
  12. {
  13.     char *word;
  14.     int delete;
  15.     struct text *next;
  16. } *start = NULL;
  17.  
  18. int main()
  19. {
  20.     create();
  21.     processing();
  22.     out();
  23.     return 0;
  24. }
  25.  
  26. void create(void)
  27. {
  28.     char string[LINE];
  29.     struct text *p;
  30.     while (scanf("%s", string) != EOF)
  31.     {
  32.         p = malloc(sizeof(struct text));
  33.         if (p == NULL)
  34.         {
  35.             printf("Ошибка! Память не выделена!");
  36.             exit (3);
  37.         }
  38.         check(string);
  39.         p -> word = malloc(strlen(string) * sizeof(char));
  40.         strcpy(p -> word, string);
  41.         p -> next = start;
  42.         start = p;
  43.     }
  44.     return;
  45. }
  46.  
  47. void check(char *string)
  48. {
  49.     struct text *t = malloc(sizeof(struct text));
  50.     char c = string[0];
  51.     if (c == toupper(c))
  52.         t -> delete = 1;
  53.     return;
  54. }
  55.  
  56. void processing(void)
  57. {
  58.     struct text *p;
  59.     for (p = start; p != NULL; p = p -> next)
  60.         if ((p -> delete) == 1)
  61.         {
  62.             putchar('1');
  63.             free(p -> word);
  64.             printf("ОСВОБОЖДЕНА ПАМЯТЬ");
  65.         }
  66.     return;
  67. }
  68.  
  69. void out(void)
  70. {
  71.     struct text *p;
  72.     for (p = start; p != NULL; p = p -> next)
  73.         printf("%s\n", p -> word);
  74.     return;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement