摘要: int me;const int * p1=&me;//p1可变,*p1不可变,此时不能用*p1来修改,但是p1可以转向int * const p2=&me;//p2不可变,*p2可变,此时允许*p2来修改其值,但是p2不能转向。const int *const p3=&me;//p3不可变,*p3也不可变,此时既不能用*p3来修改其值,也不能转向 阅读全文
posted @ 2013-09-04 16:21 泛起的鱼 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 1,字符加法#include #include void reverse(char s[]) //反向遍历{ int i; int len = strlen(s); for (i = 0; i len2 ? len1 : len2;//选取最大的作为循环长度 reverse(s1);//切换高位和地位的位置 reverse(s2);//切换高位和地位的位置 int i; int digit, carry;//digit是存储当前位数相加的值 for (i = 0, digit = 0; i int my_strlen(char s[]){ ... 阅读全文
posted @ 2013-09-04 15:36 泛起的鱼 阅读(652) 评论(0) 推荐(0) 编辑
摘要: 1,数组定义#include int main(void){ // 定义数组时需要确定: // 1. 数组元素的类型. // 2. 显式/隐式确定数组元素个数. int a[6] = { 12, 25, 36, 8, 45, 66 }; // 隐式确定数组元素个数 int b[] = { 3, 4, 5, 18, 23, 99}; // C99 // 在具有初始化式时, 数组中剩下的元素被初始化为 0 int c[] = { [0] = 36, [4] = 82 }; int i; for (i = 0; i int main(... 阅读全文
posted @ 2013-09-04 13:39 泛起的鱼 阅读(636) 评论(0) 推荐(0) 编辑
摘要: 1.。。。。。。。。。。。。。。。。。。。。#include void hanoi(char from, char pass, char to, unsigned n){ if (n == 1) { printf("%c ==> %c\n", from, to); } else { hanoi(from, to, pass, n - 1); hanoi(from, pass, to, 1); hanoi(pass, from, to, n - 1); }}void hanoi1(char... 阅读全文
posted @ 2013-09-01 19:20 泛起的鱼 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 1,函数返回值与传入参数#include void foo(void);// 如果不声明返回值类型, 那么返回值类型默认为intbar(void);// 声明没有带参数, 那么调用时可以传递任意参数.void test();//void test1(void);int main(void){ foo(); printf("world.\n"); bar(); test(3.14, "hello", 123); //test1(1, 3.14, "hello"); return 0;}void foo(void){ printf(&qu 阅读全文
posted @ 2013-08-30 11:42 泛起的鱼 阅读(545) 评论(0) 推荐(0) 编辑
摘要: 这个仅作为练习扩展使用,贴出代码,作为以后复习,不直接写结果。因为要自己推出#include int main(void){ int score; printf("pls input a score: "); scanf("%d", &score); if (score 100) { printf("wrong. score from 0 to 100.\n"); } else if (60 int main(void){ int i, j; i = 1; while (i int main(void){ ... 阅读全文
posted @ 2013-08-23 23:07 泛起的鱼 阅读(935) 评论(0) 推荐(0) 编辑
摘要: 1,if语句 1 #include 2 3 /* 4 *if (expr) 5 * stat 6 *else if (expr) 7 * stat 8 *else 9 * stat10 *11 *expr: expression12 *stat: statement -> expr; | { ... } 13 */14 15 #define EPISILON 0.000000116 17 int main(void)18 {19 double d = 5.0;20 21 // 对浮点数进行判断, 最好给一个判定范围22 /... 阅读全文
posted @ 2013-08-23 22:39 泛起的鱼 阅读(334) 评论(0) 推荐(0) 编辑
摘要: 1,九九乘法#include int main(void){ int i, j; for (i = 1; i int main(void){ int a = 3, b = 5; printf("after 0 swap, a = %d, b = %d\n", a, b); printf("------------------\n"); int t; t = a; a = b; b = t; printf("after 1 swap, a = %d, b = %d\n", a, b); printf("------------ 阅读全文
posted @ 2013-08-22 00:06 泛起的鱼 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 1,sizeof用法以及各个类型占据的字节大小#include int main(void){ char ch; int i; long l; long long ll; float f; double d; long double ld; printf("size of char : %u\n", sizeof(ch)); printf("size of int : %u\n", sizeof(int)); printf("size of long : %u\n", sizeof l); ... 阅读全文
posted @ 2013-08-20 23:42 泛起的鱼 阅读(524) 评论(0) 推荐(0) 编辑
摘要: 1. 大小写s的区别,只是多了一个预处理功能,所以后期写关于硬件的汇编使用大写S .s 汇编语言源程序;汇编.S汇编语言源程序;预处理,汇编2.编译过程 A. 预处理 使用cpp gcc -E src.c -o dst.i B. 编译阶段 gcc -S src.i -o dst.s C.汇编阶段 gcc -c src.s -o dst.o D. 链接阶段 gcc -o dst src.o最后执行 ./dst 阅读全文
posted @ 2013-08-20 23:11 泛起的鱼 阅读(410) 评论(0) 推荐(0) 编辑