随笔分类 - 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
阅读全文
摘要: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
阅读全文
摘要: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.
阅读全文
摘要: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
阅读全文
摘要: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,
阅读全文
摘要:1.#include <stdio.h>#include <malloc.h>typedef struct _soft_array{ int len; int array[];}SoftArray;int main(){ int i = 0; SoftArray* sa = (SoftArray*)
阅读全文
摘要: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(
阅读全文
摘要: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
阅读全文
摘要:#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
阅读全文
摘要:#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
阅读全文