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,15 @@
#include "Stack01a.h"
void init(Stack& s) {
s.top = EMPTY; }
void push(Stack& s, int n) {
s.arr[++s.top] = n; }
int pop(Stack& s) {
return s.arr[s.top--];}
int isEmpty(Stack& s) {
return s.top == EMPTY;}

View File

@@ -0,0 +1,17 @@
#ifndef EXAMPLE01A_STACK01A_H
#define EXAMPLE01A_STACK01A_H
#define SIZE 50
#define EMPTY (-1)
struct Stack {
int arr[SIZE];
int top;
};
void init(Stack& s);
void push(Stack& s, int n);
int pop(Stack& s);
int isEmpty(Stack& s);
#endif //EXAMPLE01A_STACK01A_H

View File

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