consolidate all repos to one for archive

This commit is contained in:
2025-01-28 13:46:42 +01:00
commit a6610fbc7a
5350 changed files with 2705721 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
#include "Stack01c.h"
#define EMPTY (-1)
Stack::Stack() {
top=EMPTY;
}
void Stack::push(int n) {
arr[++top] = n;
}
int Stack::pop() {
return arr[top--];
}
int Stack::isEmpty() {
return top == EMPTY;
}

View File

@@ -0,0 +1,19 @@
#ifndef EXAMPLE01C_STACK01C_H
#define EXAMPLE01C_STACK01C_H
#define SIZE 50
class Stack {
private:
int arr[SIZE];
int top;
public:
Stack();
void push(int n);
int pop();
int isEmpty();
};
#endif //EXAMPLE01C_STACK01C_H

View File

@@ -0,0 +1,23 @@
#include <iostream>
#include "Stack01c.h"
int main() {
Stack my_stack1, my_stack2;
my_stack1.push(7);
my_stack1.push(1);
my_stack2.push(2);
//my_stack1.top=0;
//my_stack1.arr[1]=4;
std::cout << my_stack1.pop() << " ";
std::cout << my_stack1.pop() << " ";
std::cout << std::endl;
if (my_stack1.isEmpty())
std::cout << "Stack1 is empty" << std::endl;
else
std::cout << "Stack1 isn't empty" << std::endl;
if (my_stack2.isEmpty())
std::cout << "Stack2 is empty" << std::endl;
else
std::cout << "Stack2 isn't empty" << std::endl;
return 0;
}