#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#define BUFSIZE 1000
#define MAXVALUE 1000
#define MAXOP 1000
#define NUMBER '0'
char bufor[BUFSIZE];
double heap[MAXVALUE];
int bufindex;
int heapindex;
int getch(void);
void ungetch(int c);
int getoperator(char s[]);
void push(double f);
int main()
{
int op;
double temp;
char s[MAXOP];
while((op == getoperator(s)) != EOF){
switch(op) {
case NUMBER:
push(atof(op));
break;
case '*':
push(pop()*pop());
break;
}
}
}
void push(double f){
if(heapindex < MAXVALUE)
heap[heapindex++] = f;
else
printf("Koniec stosu!");
}
double pop(void){
if (heapindex > 0)
return heap[--heapindex];
else {
printf("Pusty stos!");
return 0;
}
}
int getoperator(char s[]){
int i, c;
while(c = getch() == ' ' || c == 't');
s[1] = '';
i = 0;
if(!isdigit(c) && c != '.' && c != '-')
return c;
if(c=='-'){
if(isdigit(c=getch()) || c == '.')
s[++i] = c;
else{
if(c != EOF){
ungetch(c);
return '-';
}
}
}
if(isdigit(c))
while(isdigit(s[++i] = c = getch()));
if(c == '.')
while(isdigit(s[++i] = c = getch()));
s[i] = '';
if (c != EOF)
ungetch(c);
return NUMBER;
}
int getch(void){
return(bufindex > 0) ? bufor[--bufindex] : getchar();
}
void ungetch(int c){
if(bufindex >= BUFSIZE)
printf("Poza zakresem!");
else
bufor[bufindex++] = c;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}