题目链接:HDU 2616 Kill the monster
题意:有N个技能去打HP有M的怪兽,技能(A,M),技能伤害为A,当怪兽HP
方法一:将技能全排列,计算伤害,得到答案。
方法二:搜索,具体看代码。
全排列AC代码:
#include
#include
using namespace std;
struct node
{
int p,v;
};...
分类:
其他好文 时间:
2014-09-04 09:47:37
阅读次数:
206
在很多比较各种网络模型的文章中,但凡提到select模型时,都会说select受限于轮询的套接字数量,这个数量也就是系统头文件中定义的FD_SETSIZE值(例如64)。但事实上这个算不上真的限制。C语言的偏方:在C语言的世界里存在一个关于结构体的偏门技巧,例如: typedef struct _s...
分类:
其他好文 时间:
2014-09-04 01:36:08
阅读次数:
182
对结构体内存清零:#include #include struct STU{ int id; char sex;};int main(){ struct STU s1; memset(&s1 , 0 , sizeof(s1));}结构体内存对齐:以结构体最长的类型对齐#include #includ...
分类:
其他好文 时间:
2014-09-04 01:21:57
阅读次数:
312
第一阶段:设计结构体struct WORD{ char *key; //先测试单词长度,然后再malloc int ntrans; //记录单词解释个数 char **trans; //指针数组,每个指针都指向一个解释};malloc:11万个结构体数组 每个单词的内容 根据ntrans的个数-->...
分类:
其他好文 时间:
2014-09-03 23:58:11
阅读次数:
396
实现代码如下:#include #include #include typedef struct{ char * key; //单词的指针 int ntrans; //解释的个数 char ** trans; //解释的指针数组}WORD, * pW;//词典使用帮助信息void show_help...
分类:
其他好文 时间:
2014-09-03 23:56:37
阅读次数:
334
http://see.xidian.edu.cn/cpp/html/483.html一、指针没有指向一块合法的内存定义了指针变量,但是没有为指针分配内存,即指针没有指向一块合法的内存。浅显的例子就不举了,这里举几个比较隐蔽的例子。1、结构体成员指针未初始化struct student{ char *...
分类:
编程语言 时间:
2014-09-03 19:49:07
阅读次数:
292
线性表的链式存储结构——链表,包含单链表、双链表、循环链表等。单链表的结点由数据元素和指向下一个结点的指针构成,是最简单的一种链表结构。对单链表的操作非常多,如查找、插入、删除、逆置、打印等,现对这些操作的实现做一个小结,代码用C语言实现。#include#includetypedef struct...
分类:
其他好文 时间:
2014-09-03 19:36:47
阅读次数:
271
复习一下链表反转#include
#include
typedef int ElemType;
typedef struct Node {
int data;
struct Node* next;
}Node, *List;
//用数组arr来初始化链表中数据;此例中链表无头点
int InitList(List *list, ElemType* arr, int num)
{
int...
分类:
其他好文 时间:
2014-09-03 18:09:26
阅读次数:
168
//函数满足凸函数性质,于是三分
# include
# include
# include
# include
using namespace std;
struct node
{
double x;
double w;
};
struct node a[50010];
int n;
double cal(double xi)
{
double res=0;
...
分类:
其他好文 时间:
2014-09-03 16:53:50
阅读次数:
236
题目链接:HDU 1160 FatMouse's Speed
题意:求体重越重,反而速度越慢的例子,并输出对应的编号。
对speed进行从大到小排序,再求weight的最长上升序列,并输出路径。
AC代码:
#include
#include
#include
using namespace std;
struct Node
{
int weight;
int spee...
分类:
其他好文 时间:
2014-09-03 15:00:16
阅读次数:
214