随笔分类 - C
摘要:map和multimap默认都是按照key进行排序的用一个map统计出每个单词出现的次数,但是此时map是按照字符串排序于是我们再用一个multimap来把存储map中的内容,这是的key是int 就会按照单词出现的次数来排序也就实现了我们的目标这里之所以用multimap来临时存储是因为multimap可以存在相同的key而map是的key必须唯一 1 map word_cnt; 2 multimap ans; 3 ifstream fin("txt.txt"); 4 char p[256]; 5 while(!fin.eof()) 6 { 7 ...
阅读全文
摘要:#include #include #include #include #include "vector"
#include "queue"
using namespace std;
#define N 500
struct Bag
{ int id; int w; int v; double wv; /*friend booloperator b.wv; //结构体中,x小的优先级高 }*/ }; struct node
{ double weight; double value; double uprofi...
阅读全文
摘要:#include #include #include #include
using namespace std;
#define N 500
struct Bag
{ int id; int w; int v; double wv;
};
int C,n,Wsum,Vsum,best;
struct Bag bag[N];
int tempans[N],ans[N];
int cmp(const void *a,const void *b)
{ struct Bag *c = (Bag *) a; struct Bag *d = (Bag ...
阅读全文
摘要:fseek函数(转)int fseek(FILE *stream, long offset, int fromwhere);fseek 用于二进制方式打开的文件,移动文件读写指针位置.fseek(in,-1L,1); -- 文件流in, 零点为当前指针位置,SEEK_CUR 就是 1, -1L -- 文件指针回退1个字节int fseek( FILE *stream, long offset, int origin );第一个参数stream为文件指针第二个参数offset为偏移量,整数表示正向偏移,负数表示负向偏移第三个参数origin设定从文件的哪里开始偏移,可能取值为:SEEK_CUR、
阅读全文
浙公网安备 33010602011771号