- 博客(19)
- 收藏
- 关注
原创 课堂随笔
#include #include #include #define fun(x) x*x#define Fun(x) ((x)*(x))//预定义无分号using namespace std;int main(){ printf("fun(x) = %d\n", fun(5)); printf("Fun(x) = %d\n", Fun(5)); pri
2017-12-27 11:22:25 123
原创 字符串处理函数
参考博客http://blog.csdn.net/zmqblog/article/details/20069103#include <stdlib.h> atoi函数把字符串转换成整型数。其含义是ASCII to integer 的缩写。函数原型 int atoi(const char *nptr);该博客中有更加详细的用法。#include <string.h>st...
2017-12-18 20:09:47 101
原创 文件打开,处理数据
#include #include #include #define SCORES 4#define MAXCHARS 120typedef struct _Student{ int num; char name[30]; int score[SCORES]; int sum;} Student;Student **t; // 指向 Stu
2017-12-18 20:08:04 204
原创 c中打开文件
#include #include char inputFile[200] = "E:\\DataFile\\ScoreData.csv";//char *inputFile = "E:\\DataFile\\ScoreData.csv";FILE *fpin;//FILE相当于结构体,在函数原型里可以找到int main(){ char s[200]; int cn
2017-12-18 19:38:36 139
转载 vector 多维向量定义及其初始化
using namespace std;一维向量:vectorint> vector_1D_1;//只定义向量vectorint> vector_1D_2(n);//定义的同时初始化大小vectorint> vector_1D_3(n,m);//定义的同时初始化大小为n,元素初始值为mvectorint> vector_1D_4;vector_1D_4=vectorint>(n
2017-12-14 18:56:49 10158
原创 poj 3253(贪心 + 优先队列)
Fence RepairPOJ - 3253 Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he ne
2017-12-14 16:55:05 223
原创 三分法求单峰函数极值
模板,注意精度一般为1e-6,1e-8跟1e-10用的较少。double three_devide(double l, double r){ double left = l, right = r,mid,midmid; while(left + esp < right) { mid = (left + right)/2; midmid =
2017-12-13 21:03:43 1052
原创 在堆区,给结构体开动态内存(大小可变)
#include #include #include typedef struct _student{ int num; char name[30];} Student;Student s2[4];Student *s3[100]; Student **t;int main(){ int i, n; scanf("%d", &n);
2017-12-13 21:00:46 481
原创 欧几里得算法&&拓展欧几里得算法
参考博客http://www.cnblogs.com/void/archive/2011/04/18/2020357.html参考博客http://blog.csdn.net/zhjchengfeng5/article/details/7786595欧几里得算法int gcd(int a, int b){ return b == 0? a : gcd(b,a % b);}
2017-12-12 16:36:03 318
原创 poj 3069 Saruman's Army
Saruman's ArmySaruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the
2017-12-10 21:24:02 136
原创 debug经验
今天跟队友调了两个小时的bug,这道题我以前ac了,但还是调了这么长时间。1出现RUNTIME_ERROR [ACCESS_VIOLATION看程序中所有的数组,看是否有越界的数组。对于runtime error
2017-12-07 22:39:54 203
原创 动态规划—最大子矩阵和(两种题型)
动态规划,最重要是找到递推关系;To the MaxPOJ - 1050 Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-a
2017-12-05 20:37:03 1614
原创 hdu 1231(动态分析—最大连续子序列)
最大连续子序列HDU - 1231 给定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ Ni, Ni+1, ..., Nj },其中 1 例如给定序列{ -2, 11, -4, 13, -5, -2 },其最大连续子序列为{ 11, -4, 13 },最大和 为20。 在今年的数
2017-12-05 17:30:58 209
原创 stl学习—set
参考博客http://blog.csdn.net/ac_hexin/article/details/52042562set集合容器实现了红黑树(Red-Black Tree)的平衡二叉检索树的的数据结构,在插入元素时,它会自动调整二叉树的排列,把该元素放到适当的位置,以确保每个子树根节点的键值大于左子树所有节点的键值,而小于右子树所有节点的键值;另外,还得确保根节点的左子树的高度与有字数的高度
2017-12-05 11:19:27 127
原创 poj 3069(贪心算法之字典序排序)
Best Cow LinePOJ - 3617 FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every f
2017-12-04 20:11:17 298
原创 hdu 2037(贪心算法之区间调度问题)
今年暑假不AC “今年暑假不AC?” “是的。” “那你干什么呢?” “看世界杯呀,笨蛋!” “@#$%^&*%...” 确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。 作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6+7、超级女生,
2017-12-04 18:26:55 546
原创 next_permutation函数(全排列生成利器)
题目大意:给出一个n和一个m,要求求出数列1,2,3……nNow our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the BEelzebub has to beat our h
2017-12-04 17:40:39 209
原创 快速幂
1056.A ^ B ProblemTime Limit: 1000 MS Memory Limit: 32768 KBTotal Submission(s): 440 Accepted Submission(s): 121 Description给定三个数A, B, K, 求 A的B次方除以K的余数 。Input
2017-12-04 11:12:12 176
原创 hdu 1116(欧拉图典型应用)
参考百度文库https://wenku.baidu.com/view/b245abaad1f34693daef3eae.html欧拉回路 不重复地经过每条边的回路。欧拉路径 不重复地经过每条边的路径。欧拉图 存在欧拉回路的图。半欧拉图 存在欧拉路径的图。无向欧拉图的判定¡无向图存在欧拉回路的充要条件:连通且没有奇点。¡¡无向图存在欧拉路径的充要条件:连通且
2017-12-01 19:18:52 1544
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人