
C语言
文章平均质量分 52
iamsile
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
通过代码来判断是C++还是C
当我们创建自己的程序时,有时可能需要判断使用的是c还是c++,并对语句作相应的处理。这时我们可以通过定义_cplusplus常量。如果使用的是标准c,该常量将不被定义。 #include int main() { #ifdef __cplusplus printf("c++\n"); #else printf("c\n");原创 2013-08-09 22:20:41 · 1714 阅读 · 1 评论 -
c语言创建支持多参数多类型的函数
#include #include double test(char str[], ...) { va_list flag; double i=0.0; va_start(flag, str); while (*str) { if (*str=='%') {原创 2013-08-09 22:19:48 · 1290 阅读 · 0 评论 -
c语言的bnf总结
注:不能说是自己的原创,只能说自己是总结了下而已 translation_unit : external_decl | translation_unit external_decl ;external_decl : function_definition | decl ;function_definition : decl_specs declarator decl_list原创 2013-11-16 22:48:06 · 3710 阅读 · 1 评论 -
分词时发现的小技巧
昨儿在公司做分词系统修改的工作时,偶然发现了printf()原来可以高效的进行汉字输出,可能我的表达能力有问题,下面用代码描述: #include using namespace std; int main(int argc, char *argv[]) { char a[] = "abcdefghijklmnopqrstuvwxyz"; printf("%.*原创 2013-11-23 13:10:28 · 577 阅读 · 0 评论 -
xor
#include int main() { int n; while (scanf("%d",&n)!=EOF) { __int64 i,j,a[100010],sum1[21],ans=0; memset(a, 0, sizeof(a)); memset(sum1, 0, sizeof(sum1));原创 2013-11-13 20:23:35 · 763 阅读 · 0 评论 -
岛上的植物
#include #include using namespace std; int lenp,leno,map[101][101],v[101][101]; int n,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1},ap[1000]; bool cal(int m) { if (m==1) return 0原创 2013-11-13 20:24:39 · 852 阅读 · 0 评论 -
c++ offset define
#include using namespace std; class test { public: void show() { cout } public: int x = 10; int y = 20; }; #define offset_(x, yy) ((size_t)&((x *)nullptr)->y) int main(原创 2013-11-14 22:43:49 · 1634 阅读 · 0 评论 -
c++and c read test
#include #include #include #include #include #include using namespace std; template double benchmark(Func f, size_t iteration) { f(); timeval a,b; gettimeofday(&a, 0); for (;转载 2013-11-30 12:07:06 · 759 阅读 · 0 评论