1 class A 2 { 3 public static final int VAL = 3; // 不会导致A被加载 4 static 5 { 6 System.out.println("load A"); 7 } 8 public A(...
分类:
编程语言 时间:
2015-05-28 00:15:14
阅读次数:
166
题意:
迷宫里有一条贪食蛇,求它的蛇头到迷宫左上角最少要多少步。
分析:
关键是将蛇的状态压缩编码,然后bfs,超时就改A*,这题有类似最短路径的性质,A*发现节点重复后不需要更新直接舍弃即可。
代码:
//poj 1324
//sep9
#include
#include
#include
using namespace std;
struct state
{
int x[1...
分类:
编程语言 时间:
2015-05-27 23:02:04
阅读次数:
277
指针的点运算和箭头运算(->)
突然发现指针的两个运算符我是不太清楚的,就翻书搞了下:其实点运算和箭头运算都是访问指针所指向的 结构体或者类对象
的成员是用的操作符。比如:
struct song
{
int a;
}
有这样一个结构体,定义:
song s;
s.a=1;
song *p;
p=&s;
那么要访问指针p所指向的内存:
(*)p.a 和 p->a...
分类:
其他好文 时间:
2015-05-27 22:57:46
阅读次数:
190
一、Accessingpixel values访问像素值。(用类自带的方法:方便,但效率不高)
1. cv::Mat has the a templatemethod
at(int y, int x)
用法image.at(j,i)[channel]= value;
注意事项:the programmer needs to specify the return type ...
分类:
其他好文 时间:
2015-05-27 22:57:10
阅读次数:
594
迷宫问题
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 10001
Accepted: 5939
Description
定义一个二维数组:
int maze[5][5] = {
0, 1, 0, 0, 0,
0, 1, 0, 1, 0,
...
分类:
其他好文 时间:
2015-05-27 22:54:55
阅读次数:
161
这题还是比较坑的首先要注意两点:
1.行末没有多余的空格;
2.就是当n==1的时候单独判断;#include
using namespace std;
int main()
{
char ch;
int n,flag=0;
while(cin>>ch)
{
if(ch=='@') break;
cin>>n;...
分类:
其他好文 时间:
2015-05-27 22:54:34
阅读次数:
182
第一种方法:指针法
#include
#include
int w(int *d,int e,int g)
{
int i,j,t;
int *r;
j=0;
for(i=0;i
{
t=*(d+i);
*(d+i)=*(d+e-g+j);
*(d+e-g+j)=t;
j++; ...
分类:
其他好文 时间:
2015-05-27 22:50:16
阅读次数:
159
poj1274题意: 有n个奶牛, m个畜舍, 每个畜舍最多装1头牛,每只奶牛只有在自己喜欢的畜舍里才能产奶。 求最大产奶量。 分析: 其实题意很明显, 二分图的最大匹配, 匈牙利算法。#include#include#include#includeusing namespace std;int.....
分类:
编程语言 时间:
2015-05-27 22:46:28
阅读次数:
149
转换操作符(conversion operator) 是一种特殊的类成员函数。它定义将类类型值转变为其它类型值的转换。 1 classSmallInt 2 { 3 public: 4 SmallInt(int i =0): val(i) 5 { 6 if( i 255...
分类:
其他好文 时间:
2015-05-27 22:45:28
阅读次数:
234
protected override void WndProc(ref Message m) { if (m.Msg == 0x112) { switch ((int)m.WParam) ...