• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






天生自然

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

随笔分类 -  吴裕雄--天生自然C语言开发学习笔记

1 2 下一页

 
吴裕雄--天生自然C语言开发:约瑟夫生者死者小游戏
摘要:30 个人在一条船上,超载,需要 15 人下船。 于是人们排成一队,排队的位置即为他们的编号。 报数,从 1 开始,数到 9 的人下船。 如此循环,直到船上仅剩 15 人为止,问都有哪些编号的人下船了呢? #include int c = 0; int i = 1; int j = 0; int a[30] = { 0 }; int b[30] = { 0 }; int mai... 阅读全文
posted @ 2019-06-03 17:43 吴裕雄 阅读(453) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:排序算法
摘要:#include void bubble_sort(int arr[], int len) { int i, j, temp; for (i = 0; i arr[j + 1]) { temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = ... 阅读全文
posted @ 2019-06-03 17:38 吴裕雄 阅读(240) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:内存管理
摘要:#include #include #include int main() { char name[100]; char *description; strcpy(name, "Zara Ali"); /* 动态分配内存 */ description = (char *)malloc( 200 * sizeof(char) ); if( de... 阅读全文
posted @ 2019-06-03 17:36 吴裕雄 阅读(183) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:递归
摘要:void recursion() { statements; ... ... ... recursion(); /* 函数调用自身 */ ... ... ... } int main() { recursion(); } #include double factorial(unsigned int i) { if(i int fibonac... 阅读全文
posted @ 2019-06-03 17:33 吴裕雄 阅读(164) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:错误处理
摘要:#include #include #include extern int errno ; int main () { FILE * pf; int errnum; pf = fopen ("unexist.txt", "rb"); if (pf == NULL) { errnum = errno; fprintf(stderr... 阅读全文
posted @ 2019-06-03 17:31 吴裕雄 阅读(159) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:强制类型转换
摘要:#include int main() { int sum = 17, count = 5; double mean; mean = (double) sum / count; printf("Value of mean : %f\n", mean ); } #include int main() { int i = 17; char... 阅读全文
posted @ 2019-06-03 17:30 吴裕雄 阅读(161) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:文件读写
摘要:#include int main() { FILE *fp = NULL; fp = fopen("/tmp/test.txt", "w+"); fprintf(fp, "This is testing for fprintf...\n"); fputs("This is testing for fputs...\n", fp); fclose(fp);... 阅读全文
posted @ 2019-06-03 17:09 吴裕雄 阅读(163) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发: 输入 & 输出
摘要:#include int main() { int testInteger = 5; printf("Number = %d", testInteger); return 0; } #include int main() { float f; printf("Enter a number: "); // %f 匹配浮点型数据 sca... 阅读全文
posted @ 2019-06-03 17:08 吴裕雄 阅读(170) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:typedef
摘要:#include #include typedef struct Books { char title[50]; char author[50]; char subject[100]; int book_id; } Book; int main( ) { Book book; strcpy( book.title, "C 教程"); ... 阅读全文
posted @ 2019-06-03 17:06 吴裕雄 阅读(143) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:位域
摘要:struct { unsigned int widthValidated; unsigned int heightValidated; } status; struct { unsigned int widthValidated : 1; unsigned int heightValidated : 1; } status; #include #include /... 阅读全文
posted @ 2019-06-03 17:04 吴裕雄 阅读(238) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:共同体
摘要:union [union tag] { member definition; member definition; ... member definition; } [one or more union variables]; union Data { int i; float f; char str[20]; } data; #include... 阅读全文
posted @ 2019-06-03 17:01 吴裕雄 阅读(151) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:结构体
摘要:struct tag { member-list member-list member-list ... } variable-list ; struct Books { char title[50]; char author[50]; char subject[100]; int book_id; } book; ... 阅读全文
posted @ 2019-06-03 16:58 吴裕雄 阅读(180) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:字符串
摘要:char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'}; char greeting[] = "Hello"; #include int main () { char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'}; printf("Greeting message: %s\n... 阅读全文
posted @ 2019-06-03 16:53 吴裕雄 阅读(176) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:函数指针
摘要:#include int max(int x, int y) { return x > y ? x : y; } int main(void) { /* p 是函数指针 */ int (* p)(int, int) = & max; // &可以省略 int a, b, c, d; printf("请输入三个数字:"); scanf(... 阅读全文
posted @ 2019-06-03 16:51 吴裕雄 阅读(166) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:指针
摘要:#include int main () { int var1; char var2[10]; printf("var1 变量的地址: %p\n", &var1 ); printf("var2 变量的地址: %p\n", &var2 ); return 0; } #include int main () { int var = ... 阅读全文
posted @ 2019-06-03 16:48 吴裕雄 阅读(180) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:enum(枚举)
摘要:enum DAY { MON=1, TUE, WED, THU, FRI, SAT, SUN }; enum DAY { MON=1, TUE, WED, THU, FRI, SAT, SUN }; enum DAY day; enum DAY { MON=1, TUE, WED, THU, FRI, SAT, SUN } day; enum { ... 阅读全文
posted @ 2019-06-03 16:39 吴裕雄 阅读(220) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:数组
摘要:double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0}; double salary = balance[9]; #include int main () { int n[ 10 ]; /* n 是一个包含 10 个整数的数组 */ int i,j; /* 初始化数组元素 */ for ( i... 阅读全文
posted @ 2019-06-03 16:34 吴裕雄 阅读(247) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:作用域规则
摘要:#include int main () { /* 局部变量声明 */ int a, b; int c; /* 实际初始化 */ a = 10; b = 20; c = a + b; printf ("value of a = %d, b = %d and c = %d\n", a, b, c); return 0; } #include... 阅读全文
posted @ 2019-06-03 16:28 吴裕雄 阅读(164) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:函数
摘要:return_type function_name( parameter list ) { body of the function } /* 函数返回两个数中较大的那个数 */ int max(int num1, int num2) { /* 局部变量声明 */ int result; if (num1 > num2) result = num1;... 阅读全文
posted @ 2019-06-03 16:26 吴裕雄 阅读(249) 评论(0) 推荐(0)
吴裕雄--天生自然C语言开发:循环
摘要:while(condition) { statement(s); } #include int main () { /* 局部变量定义 */ int a = 10; /* while 循环执行 */ while( a int main () { /* for 循环执行 */ for( int a = 10; a int main ... 阅读全文
posted @ 2019-06-03 16:24 吴裕雄 阅读(138) 评论(0) 推荐(0)
 

1 2 下一页