#include <iostream>
using namespace std;
const int n = 10;
struct Stack //размерность и указатель но голову
{
int max[n];
int count;
};
void create(Stack* p)
{
p->count = 0;
}
int isEmpty(Stack* p)
{
if (p->count == 0) return 1;
else if (p->count == n) return -1;
else return 0;
}
void stkPrint(Stack* p)
{
int i;
i = p->count;
if (isEmpty(p) == 1) return;
do {
i--;
printf("%f\n", p->max[i]);
} while (i > 0);
}
void add(Stack* p)
{
int value;
cout << "enter num > "; cin >> value;
p->max[p->count] = value;
p->count++;
}
void del(Stack* p)
{
p->count--;
}
void main()
{
setlocale(LC_ALL, "rus");
Stack s;
create(&s);
char num;
do
{
cout << "1. add" << endl;
cout << "2. del" << endl;
cout << "3. вывод" << endl;
cout << "0. exit" << endl;
cout << "> "; cin >> num;
switch (num)
{
case '1':
if (isEmpty(&s) == -1) cout << endl << "stack is full\n\n";
else
{
add(&s);
cout << endl << "num is add\n\n";
} break;
//-----------------------------------------------
case '2':
if (isEmpty(&s) == 1) cout << endl << "isEmpty\n\n";
else
{
del(&s);
cout << endl << "num is del\n\n";
} break;
//-----------------------------------------------
case '3':
stkPrint(&s);
cout << endl << stkPrint;
case '0': break;
default: cout << endl << "error\n\n";
break;
}
} while (num != '0');
}
std::cout << p->max[i] << "\n"; // instead of:
// printf("%f\n", p->max[i]);
int main() //instead of void main()