This commit is contained in:
paolo.iocco
2023-03-09 10:24:21 +00:00
parent 1b2787b9ad
commit ab6f495c89
575 changed files with 173384 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
/*
* A stack.
*
*/
string m_ary[];
char FIELD_SEP = '\t';
char RECORD_SEP = '\n';
string push(string stack, string entry)
{
return stack + entry + RECORD_SEP;
}
string top(string stack)
{
int num = strsplit(m_ary, stack, RECORD_SEP);
return m_ary[num - 1];
}
string pop(string stack)
{
int off = strrchr(stack, RECORD_SEP, -2);
return strsub(stack, off);
}
string bottom(string stack)
{
return "";
}
string shift(string stack)
{
return "";
}
string unshift(string stack, string entry)
{
return "";
}
string t;
t = push(t, "aaa");
t = push(t, "bbb");
t = push(t, "ccc");
string msg;
string qqq;
sprintf(msg, "stack:\n%s", t);
qqq = qqq + msg;
string s;
s = top(t);
sprintf(msg, "top:\n%s", s);
qqq = qqq + msg;
t = pop(t);
s = top(t);
sprintf(msg, "top:\n%s", s);
qqq = qqq + msg;
t = push(t, "ddd");
sprintf(msg, "stack:\n%s", t);
qqq = qqq + msg;
dlgMessageBox(qqq);