C语言学习札记
孤独的娃娃菜
!!!!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
struct和typedef struct
分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int a; }Stu; 于是在声明变量的时候就可:Stu stu1;(如果没有typedef就必须用struct Student stu1;来声明) 这里的Stu实际上就是转载 2016-07-12 19:52:42 · 947 阅读 · 0 评论 -
C/C++ sort从大到小排序
重写cmp函数#include <iostream> #include <algorithm> using namespace std; bool cmp(int a,int b){ return a > b; } int main(){ int a[] = {5,3,7,3,9,4}; sort(a,a+6,cmp); for(...原创 2018-06-22 15:03:55 · 22738 阅读 · 0 评论 -
字符串排序/字典序最小拼接方式
改写cmp函数#include <iostream> #include <algorithm> using namespace std; bool cmp(const string &a,const string &b){ return a+b < b+a; } int main(){ string str[100]; i...原创 2018-06-22 15:18:09 · 1055 阅读 · 0 评论 -
C qsort 函数改写比较函数
#include <iostream> #include <algorithm> #include <cstdlib> using namespace std; int comp(const void* a,const void* b){ int *p1,*p2; p1 = (int *)a; p2 = (int *)b; r...原创 2018-06-22 15:37:25 · 367 阅读 · 0 评论 -
C/C++ 精度损失下的浮点数比较
等于运算符(==)const double eps = 1e-8; #define Equ(a,b) (fabs((a)-(b))<(eps))大于运算符(>)const double eps = 1e-8; #define More(a,b) (((a)-(b))>(eps))小于运算符(<)const double eps = 1e-8; #define Less(a,...原创 2018-07-03 15:37:14 · 900 阅读 · 0 评论
分享