2012年3月31日

NYOJ 35题 表达式求值,四则运算(栈实现) 严蔚敏

摘要: 这些函数中都有“重复”的,因为操作数(OPND)栈用double,操作符(OPTR)栈用char。C++中的模板可以解决这个问题吗?这是对着书写的:#include <iostream> using namespace std; #define STACK_INIT_SIZE 100 #define STACKINCREMENT 100 char Precede_Matrix[7][7] = { {'>', '>', '<', '<', '<', '>' 阅读全文

posted @ 2012-03-31 22:13 jjtx 阅读(356) 评论(0) 推荐(0) 编辑

括号匹配(栈实现)

摘要: #include <cstdio> #include <iostream> using namespace std; #define MAXSIZE 20 typedef struct { char *base; char *top; int stacksize; }SqStack; void InitStack(SqStack &S) { S.base = (char *)malloc( MAXSIZE * sizeof(char) ); if(S.base == NULL) exit(-2); S.top = S.base; S.stacksize = MA 阅读全文

posted @ 2012-03-31 13:17 jjtx 阅读(185) 评论(0) 推荐(0) 编辑

文字常量区,字符串常量

摘要: 可以:#include <stdio.h> int main(void) { char str[8] = {0}; str[0] = *"jiang"; printf("%s\n", str); return 0; }2012/5/16 更新补充一个例子(正确):#include <iostream> using namespace std; int main(void) { cout << "0123456789"[5] << endl; return 0; }输出结果是5 阅读全文

posted @ 2012-03-31 00:50 jjtx 阅读(152) 评论(0) 推荐(0) 编辑

导航