Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- struct Node
- {
- char data;
- Node* next;
- };
- void AddNode(Node*& first, char letter)
- {
- Node* cur;
- if (first == NULL)
- {
- first = new Node;
- first->data = letter;
- first->next = NULL;
- cur = first;
- }
- else
- {
- cur = new Node;
- cur->data = letter;
- cur->next = first;
- first = cur;
- }
- }
- void OutputList(Node* first)
- {
- while (first != NULL)
- {
- printf("%c ", first->data);
- first = first->next;
- }
- }
- void InsertSymbol(Node*& cur)
- {
- Node* symbol = new Node;
- symbol->data = '!';
- symbol->next = cur->next;
- cur->next = symbol;
- }
- void Function(Node*& first)
- {
- Node* cur = first;
- if (strchr("aeiouy", cur->data) != NULL)
- AddNode(first, '!');
- while (cur->next != 0)
- {
- if (strchr("aeiouy", cur->next->data) != NULL)
- {
- InsertSymbol(cur);
- cur = cur->next;
- }
- cur = cur->next;
- }
- }
- int main()
- {
- const int n = 80;
- char str[n];
- Node* first = NULL, *cur = NULL;
- puts("Enter the string:");
- gets_s(str);
- for (int i = 0; i < strlen(str); i++)
- AddNode(first, str[i]);
- puts("\nFormed list:");
- OutputList(first);
- puts("\n\nExtended list:");
- Function(first);
- OutputList(first);
- return 0;
- }
Add Comment
Please, Sign In to add comment