Professional Documents
Culture Documents
Programmation de l’ordinateur
Chișinau 2020
#include <iostream>
#include <cstdlib>
#include <cstring>
double *Stack;
int sPtr;
void init()
{
Stack=new double[100];
sPtr=0;
}
void del()
{
delete [] Stack;
}
void Push(int z)
{
Stack[sPtr++]=z;
}
int Pop()
{
return Stack[--sPtr];
}
Push(atof(Tmp));
switch (s)
{
case '>':
num1=Pop();
num2=Pop();
if(num1 > num2){
Push(1);
} else{
Push(0);
}
break;
case '<':
num2=Pop();
num1=Pop();
if(num1 < num2) {
Push(1);
} else{
Push(0);
}
break;
case '#':
num2=Pop();
num1=Pop();
if(num1 != num2) {
Push(1);
} else {
Push(0);
}
break;
}
}
}
return Pop();
}
int main()
{
char *exp="34#";
init();
cout << exp << " = ";
cout << eval(exp);
del();
return 0;
}
#include <iostream>
#include <cstring>
#include <cmath>"
char *str;
int num[20];
int top;
}stack;
tp->top = 0;
return 0;
}
void push_calc(stack *stk, int n_b){
stk->num[stk->top] = n_b;
stk->top++;
} else{
cout << "Стек полон " << stk->top;
}
}
int end = 0;
if(stk->top > 0) {
stk->top--;
end = stk->num[stk->top];
return end;
} else{
cout << "Stack ne a les variables pas";
return 0;
}
}
//
***********************************************************************************************
********************
switch(op){
case '+':
x = x + y;
break;
case '-':
x = x - y;
break;
case '*':
x = x * y;
break;
case '/':
x = x / y;
break;
case '%':
x = x % y;
break;
default:
break;
}
stack *stk;
stk = new(stack);
init(stk);
while (x != 0) {
ost = x % 2;
x = x / 2;
push_calc(stk,ost);
kappa++;
}
puts("");
}
int main() {
calc('+',resul,resul1);
return 0;
}
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#define M 10
struct node{
int info;
struct node *l, *r;
};
if((*t) == NULL){
*t = (struct node*)malloc(sizeof(struct node));
(*t)->info = a;
(*t)->l = (*t)->r = NULL;
return;
}
if(a > (*t)->info){
makeHeap(a, &(*t)->l);
} else {
makeHeap(a, &(*t)->r);
}
int main () {
int a[M]={0,6,2,8,4,1,7,3,9,5};
int n=9,s;