- 博客(24)
- 收藏
- 关注
原创 1007. 素数对猜想 (20) PAT+素数表
让我们定义 dn 为:dn = pn+1 - pn,其中 pi 是第i个素数。显然有 d1=1 且对于n>1有 dn 是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。现给定任意正整数N (5),请计算不超过N的满足猜想的素数对的个数。输入格式:每个测试输入包含1个测试用例,给出正整数N。输出格式:每个测试用例的输出占一行,不超过N的满足猜想的素数对的个数。
2014-02-20 14:51:22
617
原创 1017. A除以B (20) PAT
本题要求计算A/B,其中A是不超过1000位的正整数,B是1位正整数。你需要输出商数Q和余数R,使得A = B * Q + R成立。输入格式:输入在1行中依次给出A和B,中间以1空格分隔。输出格式:在1行中依次输出Q和R,中间以1空格分隔。输入样例:123456789050987654321 7输出样例:17636684150141093474 3
2014-02-20 13:33:23
410
原创 python学习笔记(不断更新...)
1.序列类型对象的浅拷贝是默认类型拷贝,并可以以下几种方式实施:(1)完全切片操作[:];(2)利用工厂函数,比如list()、dict()等;(3)使用copy模块的copy函数
2013-12-09 22:38:02
396
原创 python3.X与之前版本的不同(不断更新...)
正在学习《Python核心编程(第二版)》书中貌似是针对python2.x讲的,目前的python最新版本是python3.x,当然不能为了顺利看完书而用比较老的python,特写该博客,一边学习,一边记录python3.x与python2.x的不同之处。
2013-11-21 20:34:04
1028
原创 1018. 锤子剪刀布 (20) PAT+运行超时
注意:用cin,cout输入输出时,最后一个case超时,改为scanf,printf后,全部case通过。题目:大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如图所示:现给出两人的交锋记录,请统计双方的胜、平、负次数,并且给出双方分别出什么手势的胜算最大。输入格式:输入第1行给出正整数N(5),即双方交锋的次数。随后N行,每行给出一次交
2013-11-20 11:11:45
883
原创 int转string string转int CString转Char*
int转stringint n;string s;stringstream stream;stream << n;stream >> s;string转intint n;string s;n = atoi(s.c_str());CString转Char*char* CStringToCharArray(CString str){ char *p
2013-11-14 10:45:05
339
原创 1072. Gas Station (30) PAT+Dijkstra单源最短路径
题目:1072. Gas Station (30) A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However
2013-11-13 21:36:59
1091
原创 C++ Primer学习笔记——basis
1、IDE:integrated development environment2、initialized variable: those that are given a value when theyare defined uninitialized variable:those that are not given an initial value3、end-of-file:
2013-01-23 11:29:52
192
原创 OpenCV绘制基本图形和文字
以下代码是利用OpenCV绘制基本图形和文字,文字限于英文,对于中文,日后会更新~#include "cv.h"#include "highgui.h"int main(){ IplImage* img = cvCreateImage(cvSize(300,300),IPL_DEPTH_8U, 3); cvLine(img, cvPoint(0,0), cvPoint(100,100)
2013-01-23 11:29:50
376
原创 OpenCV2.4.3在vs2010下的配置
环境:XP+vs2010+opencv2.4.3其中,我的opencv2.4.3安装目录为E:\Program Files\OpenCV\OpenCV2.4.3下面直接上配置步骤~1、设置环境变量:在系统变量中增加path:E:\ProgramFiles\OpenCV\OpenCV2.4.3\opencv\build\x86\vc10\bin 2、vs2010中的设置,我建
2013-01-23 11:29:48
526
原创 例6-1 使用cvHoughCircles返回在灰度图中找到的圆序列
#include "cv.h"#include "highgui.h"#include "math.h"int main(){ IplImage* image = cvLoadImage("3.png",CV_LOAD_IMAGE_GRAYSCALE); CvMemStorage* storage =cvCreateMemStorage(0); cvSmooth(image, imag
2013-01-23 11:29:44
652
原创 例5-2 cvThreshold函数的用法
#include "stdio.h"#include "cv.h"#include "highgui.h"void sum_rgb(IplImage*src, IplImage* dst){ IplImage* r = cvCreateImage(cvGetSize(src),IPL_DEPTH_8U, 1); IplImage* g = cvCreateImage(cvGetSize(
2013-01-23 11:29:39
429
原创 例4-2 使用滑动条实现开关功能
#include "cv.h"#include "highgui.h"int g_switch_value =0;IplImage* img =cvLoadImage("lena.bmp");IplImage* temp = cvCreateImage(cvGetSize(img),img->depth,img->nChannels);voidswitch_on_function(){
2013-01-23 11:29:37
279
原创 例4-1 用鼠标在窗口中画方形
#include "cv.h"#include "highgui.h"voidmy_mouse_callback(int ievent, int x, int y, int flags, void*param);CvRect box;bool drawing_box = false;void draw_box(IplImage*img, CvRect rect){ cvRectangl
2013-01-23 11:29:35
314
原创 例3-14 alpha融合ROI
#include "cv.h"#include "highgui.h"int main(){ IplImage* src1; IplImage* src2; src1 = cvLoadImage("lily.png"); src2 = cvLoadImage("lena.bmp"); cvNamedWindow("src1"); cvShowImage("src1", src1);
2013-01-23 11:29:32
757
1
原创 例3-13 其他widthStep方法把sub_img的所有像素值增加150
#include "cv.h"#include "highgui.h"int main(){ IplImage* interest_img =cvLoadImage("lena.bmp"); CvRect interest_rect =cvRect(100,200,300,300); IplImage* sub_img =cvCreateImageHeader(
2013-01-23 11:29:30
692
原创 例3-12 用imageROI来增加某范围的像素
#include "cv.h"#include "highgui.h"int main(){ IplImage* src; if((src=cvLoadImage("Lena.bmp")) != 0){ int x = 100; int y = 200; int width = 300; int height = 300; int add = 150; cvSetI
2013-01-23 11:29:28
466
原创 例2-6 cvCanny
#include "cv.h"#include "highgui.h"IplImage*doCanny(IplImage* in, double lowThresh, double highThresh, doubleaperture){ if(in->nChannels != 1) return 0; IplImage* out = cvCreateImage(cvGetSize(i
2013-01-23 11:29:24
321
原创 例2-5 cvPyrDown
#include "cv.h"#include "highgui.h"IplImage*doPyrDown(IplImage* in, int filter = IPL_GAUSSIAN_5x5){ assert(in->width%2 ==0&& in->height%2==0); IplImage* out =cvCreateImage(cvSize(in->width/2,in->h
2013-01-23 11:29:22
461
原创 例2-4 cvSmooth
#include "cv.h"#include "highgui.h"int main(){ cvNamedWindow("Example4-in"); cvNamedWindow("Example4-out"); IplImage* image = cvLoadImage("lena.bmp"); cvShowImage("Example4-in", image); IplIma
2013-01-23 11:29:19
276
原创 例2-3 窗口添加滚动条
#include "cv.h"#include "highgui.h"int g_slider_position =0;CvCapture* g_capture = NULL;void onTrackbarSlide(intpos){ cvSetCaptureProperty(g_capture,CV_CAP_PROP_POS_FRAMES, pos);}int main(i
2013-01-23 11:29:17
206
原创 例2-2 显示视频
#include"highgui.h"int main(int argc, char**argv){ cvNamedWindow("Examp#include"highgui.h"int main(int argc, char**argv){ cvNamedWindow("Example2",CV_WINDOW_AUTOSIZE); CvCapture* capture =cvCre
2013-01-23 11:29:13
213
原创 例2-1 显示图像
#include"highgui.h"int main(int argc,char** argv){ IplImage* img = cvLoadImage(argv[1]); cvNamedWindow("Example1",CV_WINDOW_AUTOSIZE); cvShowImage("Example1", img); cvWaitKey(0); cvReleaseImag
2013-01-23 11:29:11
176
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人