![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
杂
lanxuan365
这个作者很懒,什么都没留下…
展开
-
结构体排序
#include <iostream>#include <algorithm>using namespace std;struct st{ int a,b;};bool cmp(st x,st y){ if (x.a>y.a) return 1; else return 0;}int main(){st s[10];int i;for (i=0;i<10;i++){ s[i原创 2015-08-10 19:55:24 · 303 阅读 · 0 评论 -
poj1753
翻转棋,枚举所有情况 加入一些位运算 x^1可以实现0变1,1变0 x&1可以取最后一位 0-65535循环一遍//// main.cpp// poj1753//// Created by 耿飞 on 15/8/12.// Copyright (c) 2015年 耿飞. All rights reserved.//#include <iostream>#include原创 2015-08-12 15:52:20 · 293 阅读 · 0 评论 -
点的旋转
任意点(x,y),绕一个坐标点(rx0,ry0)逆时针旋转a角度后的新的坐标设为(x0, y0),有公式:x0= (x - rx0)*cos(a) - (y - ry0)*sin(a) + rx0 ;y0= (x - rx0)*sin(a) + (y - ry0)*cos(a) + ry0 ;原创 2015-08-10 20:13:06 · 578 阅读 · 0 评论 -
sprintf
printf就是把后面的东西写入到屏幕,而sprintf就是把后面的东西格式化为字符串写入到字符串中具体用法举例:sprintf(s,”% 20.5f”,100.0);printf(“%s\n”,s)屏幕输出“ 100.00000”sprintf(s,”% 20.5d”,100);printf(“%s\n”,s)屏幕输出“ 0.00000”原因是100没有原创 2015-08-10 20:11:18 · 805 阅读 · 0 评论 -
模拟退火——模板
#include <cstdio>#include <cmath>#include <algorithm>const double lim=0.999999;const double eps=1e-2;const double pi=3.141592653589793;double tmp,maxx,minx,maxy,miny,lx,ly,dif;int n,ns,nc;double ans;us原创 2015-08-10 20:09:51 · 600 阅读 · 0 评论 -
字符串hash
unsigned int ELFHash(char *str){ unsigned int hash = 0; unsigned int x = 0; while (*str) { hash = (hash << 4) + (*str++); if ((x = hash & 0xF0000000L) != 0) {原创 2015-08-10 20:08:05 · 374 阅读 · 0 评论 -
poj2001字典树
#include <cstdio>#include <cstring>using namespace std;typedef char st[22];st str[20003];st s;int p=0;struct tree_node{ int count; tree_node *next[26];}root ,node[20003];void insert(char *word){原创 2015-08-10 20:07:05 · 342 阅读 · 0 评论 -
A Bug's Life(分组并查集 奇偶表)
Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of the opposite gend原创 2015-08-10 20:04:52 · 345 阅读 · 0 评论 -
c风格字符串
#include <iostream>#include <cstring>using namespace std;struct dd{ int a;double b;};struct aa{ dd t,q;};struct qq{ aa o;};int main(){ qq z[10]; z[0].o.t.a=10;//结构体的嵌套格式 std::ios::syn原创 2015-08-10 20:01:45 · 268 阅读 · 0 评论 -
HOJ1062 贪心+优先队列
#include <cstdio>#include <queue>using namespace std;main(){ int n,i,k;int a[50002]; scanf("%d",&n); while(n!=0) { for (i=1;i<=n;i++) scanf("%d",&a[i]); priority_queue<int,vec原创 2015-08-10 19:59:30 · 276 阅读 · 0 评论 -
优先队列——重载运算符
#include#include#include #define PQ priority_queueusing namespace std;struct sq{ int a,b; friend bool operator < (sq x,sq y){ return x.a>y.a;}};int main(){原创 2015-08-10 19:57:28 · 795 阅读 · 0 评论 -
2015 Multi-University Training Contest 9-1007 Travelling Salesman Problem
Problem DescriptionTeacher Mai is in a maze with n rows and m columns. There is a non-negative number in each cell. Teacher Mai wants to walk from the top left corner (1,1) to the bottom rig原创 2015-08-19 10:01:35 · 562 阅读 · 0 评论