随笔分类 -  C语言实例

摘要:#include <stdio.h>int main(){ int i = 0; // int j = ++i+++i+++i; int a = 1; int b = 2; int c = a+++b; int* p = &a; printf("c=%d\n",c); b = b; return 0 阅读全文
posted @ 2016-12-08 18:11 王小波私人定制 阅读(145) 评论(0) 推荐(0)
摘要:1.#include <stdio.h>#define SWAP1(a,b) \{ \ int temp = a; \ a = b; \ b = temp; \}#define SWAP2(a,b) \{ \ a = a + b; \ b = a - b; \ a = a - b; \}#defin 阅读全文
posted @ 2016-12-08 18:07 王小波私人定制 阅读(228) 评论(0) 推荐(0)
摘要:1.#include <stdio.h>int main(){ int i = 0; int j = 0; if( ++i > 0 || ++j > 0 ) { printf("%d\n", i); printf("%d\n", j); } return 0;} 2.#include <stdio. 阅读全文
posted @ 2016-12-08 18:05 王小波私人定制 阅读(183) 评论(0) 推荐(0)
摘要:1.#include <stdio.h>int main(){ char c = " "; while( c=="\t" || c==" " || c=="\n" ) { scanf("%c", &c); } return 0;} 2.#include <stdio.h>int main(){ ch 阅读全文
posted @ 2016-12-08 18:04 王小波私人定制 阅读(219) 评论(0) 推荐(0)
摘要:1.#include <stdio.h>#define SWAP(a,b) \{ \ int temp = a; \ a = b; \ b = temp; \}int main(){ int a = 1; int b = 2; SWAP(a,b); printf("a=%d, b=%d\n", a, 阅读全文
posted @ 2016-12-08 18:02 王小波私人定制 阅读(198) 评论(0) 推荐(0)
摘要:1.#include <stdio.h>#include <malloc.h>typedef struct _soft_array{ int len; int array[];}SoftArray;int main(){ int i = 0; SoftArray* sa = (SoftArray*) 阅读全文
posted @ 2016-12-08 17:54 王小波私人定制 阅读(134) 评论(0) 推荐(0)
摘要:1.#include <stdio.h>void func(int n){ int* p = NULL; if( n < 0 ) { goto STATUS; } p = malloc(sizeof(int) * n); STATUS: p[0] = n; }int main(){ f(1); f( 阅读全文
posted @ 2016-12-08 17:43 王小波私人定制 阅读(196) 评论(0) 推荐(0)
摘要:1.#include <stdio.h>void f1(int i){ if( i < 6 ) { printf("Failed!\n"); } else if( (6 <= i) && (i <= 8) ) { printf("Good!\n"); } else { printf("Perfect 阅读全文
posted @ 2016-12-08 17:39 王小波私人定制 阅读(198) 评论(0) 推荐(0)
摘要:#include <stdio.h>int main() { auto int i = 0; register int j = 0; static int k = 0; printf("auto %d:",i); printf("register %d:",j); printf("static %d 阅读全文
posted @ 2016-12-08 17:36 王小波私人定制 阅读(165) 评论(0) 推荐(0)
摘要:#include <stdio.h>int main(){ char c = 0; short s = 0; int i = 0; printf("%d, %d\n", sizeof(char), sizeof(c)); printf("%d, %d\n", sizeof(short), sizeo 阅读全文
posted @ 2016-12-08 17:31 王小波私人定制 阅读(125) 评论(0) 推荐(0)

DON'T FORGET TO HAVE FUN