Вот примерный код, но по идеи он записывает слова которые не начинаются на заданную букву. И выдает ошибку, помогите пожалуйста исправить ошибки и сделать чтобы выводились слова которые не заканчиваются на заданную букву. (ошибки на картинках)
Код: Выделить всё
#include <iostream>
#include <string>
using namespace std;
struct stack {
string inf;
stack *next;
};
void push(stack *&s, string val)
{
stack *ins = new stack;
ins->inf = val;
ins->next = s;
s = ins;
}
string top(stack *s)
{
return s->inf;
}
string pop(stack *&s)
{
stack *temp = s->next;
string val = s->inf;
s = temp;
delete s;
return val;
}
bool empty(stack *s)
{
return (s == NULL);
}
int main()
{
int n;
string x;
stack *s = NULL;
cout << "Vvedite kol-vo elementov";
cin >> n;
cout << "Vvedite elements stack:\n";
for (int i = 0; i < n; i++)
{
cin >> x;
push(s, x);
}
char y;
cout << "Bukva:";
cin >> y;
stack *temp = NULL;
while (!empty(s))
{
x = pop(s);
if (x[0] != y)
push(temp,pop(s));
}
while (!empty(temp))
cout << pop(temp) << " ";
system("pause");
return 0;
}