摘要:
一,宏定义:在预处理的时候把宏定义的内容替换到代码中,正常编译。1,无参数宏定义和有参数宏定义 (1)宏定义不能加分号,比如:#define PI 3.24;错的,#define PI 3.24对的。 (2)带参数宏定义,注意参数用括号包起来,因为参数有可能表达式;宏名和形参之间不能有空格。 (3)带参数宏定义和带参数的函数,在使用时候有差别的。 带参数函数示例: #include int SQ(int);int main(){ int i=1; while(iint main(){ int i=1; while(i<=5) printf("%d\n",SQ(i++) 阅读全文
摘要:
一,基本模式匹配算法#include#include using namespace std;int main(){ char str1[] = "abchelloefg"; char str2[] = "hello"; int i = 0, j = 0, flag = 0, len1 = strlen(str1), len2 = strlen(str2); for (i = 0; i using namespace std;const int N = 100;void setNext(char *str, int len, int *next){ ne 阅读全文