234234234

随笔分类 -  C语言

慢慢来
摘要:#include <stdio.h> int main() { int n = 0; while(scanf("%lld", &n) && n > 0) { long long sum = 0; for(int i = 1; i <= n; i++) { long long factorial = 阅读全文
posted @ 2022-07-03 15:54 你若愿意,我一定去 阅读(80) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { for(int a = 1; a < 10; a++) for(int b = 1; b < 10; b++) for(int c = 1; c < 10; c++) { if (a*a*a + b*b*b + c*c*c == a*1 阅读全文
posted @ 2022-07-03 15:45 你若愿意,我一定去 阅读(342) 评论(0) 推荐(0) 编辑
摘要:最近遇到一道题,要求以ctrl+z作为键盘输入来结束条件,之前没有遇到过,然后就动手测试了一番。 int main() { int n; while(1) { int g = scanf("%d", &n); printf("%d\n", g); } return 0; } 通过上面的这段代码,我只 阅读全文
posted @ 2020-11-24 19:47 你若愿意,我一定去 阅读(677) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main(int argc, char * argv[]) { int x;float y; scanf("%2d%f", &x, &y); printf("%d %f", x, y); return 0; } 阅读全文
posted @ 2020-09-29 17:29 你若愿意,我一定去 阅读(236) 评论(0) 推荐(0) 编辑
摘要:简单记录一下: 以#define ABC(x) x*x 为例 错误的认识:int a = 3; 则 ABC(a+1)=(a+1)*(a+1)=4*4=16 正确:int a = 3; 则ABC(a+1)=a+1*a+1=7 (把x直接用a+1替换) 额,不知道这样讲哦不哦看 更新下......... 阅读全文
posted @ 2020-09-29 17:12 你若愿意,我一定去 阅读(132) 评论(0) 推荐(0) 编辑
摘要:参考博客:http://c.biancheng.net/view/2054.html 交大家一个记忆的方法,我觉得挺好用: 第一:记住全称 。r=>read(读), w=>write(写), a=>append(追加),这个应该是最好记住的。 第二:打开失败。包含r打开方式的,文件不存在就会打开失败 阅读全文
posted @ 2020-09-29 16:50 你若愿意,我一定去 阅读(163) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main(int argc, char * argv[]) { // 参数的个数,包括自身的文件名 printf("%d\n", argc); int i = 0; while(i < argc) { printf("%s\n", argv[i++]); 阅读全文
posted @ 2020-09-29 16:24 你若愿意,我一定去 阅读(142) 评论(0) 推荐(0) 编辑
摘要:// 主对角线法 ,不管是怎么求值,row始终是要往下移 int CalDeterminant( int (*data)[vertexNum|1],// 行列式,下标从1开始 int n// 行列式大小 ) { int r0, r1,row,col; int value; // 反 r0 = 0; for (int i = n; i >=... 阅读全文
posted @ 2019-07-20 22:26 你若愿意,我一定去 阅读(1241) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { int a = 3; // 二进制为 0000 0000 0000 0000 0000 0000 0000 0011 int b = 6; // 二进制为 0000 0000 0000 0000 0000 0000 0000 0110 阅读全文
posted @ 2018-06-23 13:41 你若愿意,我一定去 阅读(199) 评论(0) 推荐(0) 编辑
摘要:动态内存分配主要的函数有: malloc(), realloc(), calloc() 都包含在头文件 #include <stdlib.h> 里 这几个函数的定义: void *__cdecl malloc(size_t _Size); // 返回的是内存的首地址 void *__cdecl re 阅读全文
posted @ 2018-06-23 13:38 你若愿意,我一定去 阅读(87) 评论(0) 推荐(0) 编辑
摘要:strcmp(); 比较两个字符串,相同时返回0,不相同时返回-1; 阅读全文
posted @ 2018-06-20 20:00 你若愿意,我一定去 阅读(169) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { typedef int myint; // 为int 类型取自己想要的名字 myint a = 10; printf("%d", a); return 0;} 其他类型的用法也是一样的 typedef 类型 自己想要取得名字; 阅读全文
posted @ 2018-06-18 23:56 你若愿意,我一定去 阅读(356) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2018-06-11 19:59 你若愿意,我一定去 阅读(115) 评论(0) 推荐(0) 编辑
摘要:源码,反码,补码的概念 原码: 是该数的绝对值 第一位为符号位: 正数为 0, 负数为: 1 例如: +6: 0000 0000 0000 0000 0000 0000 0000 0110 -6: 1000 0000 0000 0000 0000 0000 0000 0110 反码: 正数的反码和原 阅读全文
posted @ 2018-06-11 19:29 你若愿意,我一定去 阅读(256) 评论(0) 推荐(0) 编辑
摘要:例子:利用外部函数求两个整数中较大值与较小值的差。 想法:设函数Max求两个整数的较大值,函数Min求两个整数的较小值,主函数调用函数Max和Min求得整数x和y中的较大值max和较小值min,则max-min即为所求。可以将程序分解为3个源文件,其中,源文件func1.cpp完成求两个整数的较大值 阅读全文
posted @ 2018-06-10 22:11 你若愿意,我一定去 阅读(1084) 评论(0) 推荐(0) 编辑
摘要:如果文件A要引用文件B中定义的外部变量,则在文件A中用关键字extern声明该外部变量,即可将该外部变量的作用域扩展到文件A中。 extern int count; //声明外部变量countextern int data[ ]; //声明外部数组data,无须指明数组长度 关键字extern提示编 阅读全文
posted @ 2018-06-10 21:56 你若愿意,我一定去 阅读(807) 评论(0) 推荐(0) 编辑
摘要:// 要解决的问题(个人感受):代码模块化,有点大化小的感觉,主要的是为了代码更让人易懂,代码的重用性更高,不重复造轮子,代码的维护性更好。 // 比如你要计算几个规则图形的总面积:可以这样划分程序,计算矩形体积为一个函数, 计算圆形体积为一个函数// 计算三角形体积为一个函数,暂时就算这三个的面积 阅读全文
posted @ 2018-06-10 21:42 你若愿意,我一定去 阅读(888) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> // 时间结构体hour, minute, secondtypedef struct Time{int H;int M;int S;} time; int main() {time t1, t2;// t1 是开始时间, t2 是截至时间,它们之间的最大时间差为 阅读全文
posted @ 2018-05-29 22:29 你若愿意,我一定去 阅读(137) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> union Num{ unsigned long int a; unsigned short int arr[2];} Num; int main() { while(scanf("%x", &Num.a) != EOF) printf("height=%x l 阅读全文
posted @ 2018-05-09 23:22 你若愿意,我一定去 阅读(177) 评论(0) 推荐(0) 编辑

23423423423
点击右上角即可分享
微信分享提示