cstring

C++ boost.python折腾笔记

孤人 提交于 2020-10-30 08:19:42
为了让当年研究生时写的图像处理系统重出江湖起到更大的作用,应研究生导师的意见,对原有的c++框架做了python扩展处理,为了避免遗忘,备注如下: 一、boost 编译 下载boost源码,这里使用boost 1.67,解压到目录,进行编译 下载C++的boost库: http://www. boost.org/ 安装Anaconda3-5.1.0-Windows-x86_64 默认路径安装 解压boost文件,在其目录中执行 .\bootstrap.bat ,会生成编译器 b2.exe 和 bjam.exe 修改 project-config.jam 文件,加入python的版本及路径(不加入则会默认python2): import option ; using msvc ; option.set keep-going : false ; using python : 3.6 # Version : C:\\ProgramData\\Anaconda3\\python.exe # Python Path : C:\\ProgramData\\Anaconda3\\include # include path : C:\\ProgramData\\Anaconda3\\libs # lib path(s) ; 执行命令(我这里是vs 2010 故为msvc-10.0) `.

天梯赛L1 题解

百般思念 提交于 2020-10-29 13:51:42
L1-001 Hello World (5 分) 这道超级简单的题目没有任何输入。 你只需要在一行中输出著名短句“Hello World!”就可以了。 AC代码:(直接输出记性) #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; typedef long long LL; const int maxn= 10005 ; int main() { printf( " Hello World!\n " ); return 0 ; } L1-002 打印沙漏 (20 分) 本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印 ***** *** * *** ***** 所谓“沙漏形状”,是指每行输出奇数个符号;各行符号中心对齐;相邻两行符号数差2;符号数先从大到小顺序递减到1,再从小到大顺序递增;首尾符号数相等。 给定任意N个符号,不一定能正好组成一个沙漏。要求打印出的沙漏能用掉尽可能多的符号。 输入样例: 19 * 输出样例: ***** *** * *** ***** 2 解法:我们先求出共有多少层,然后根据层数输出。 AC代码: #include <iostream>

PAT 甲级真题题解(63-120)

余生长醉 提交于 2020-10-29 04:36:08
1063 Set Similarity n个序列分别先放进集合里去重。在询问的时候,遍历A集合中每个数,判断下该数在B集合中是否存在,统计存在个数(分子),分母就是两个集合大小减去分子。 1 // 1063 Set Similarity 2 #include < set > 3 #include <map> 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 using namespace std; 8 9 set < int > se[ 55 ]; 10 11 int main() { 12 int n, k, m; 13 scanf( " %d " , & n); 14 for ( int i = 1 ; i <= n; i++ ) { 15 scanf( " %d " , & m); 16 while (m-- ) { 17 scanf( " %d " , & k); 18 se[i].insert(k); 19 } 20 } 21 scanf( " %d " , & k); 22 while (k-- ) { 23 int id1, id2; 24 double cnt = 0 , total = 0 ; 25 scanf( " %d %d " , &id1, & id2); 26 for (

PAT甲级第二次真题练习

萝らか妹 提交于 2020-10-29 01:28:53
1005 Spell It Right (20)(20 分) 提问 Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specification: Each input file contains one test case. Each case occupies one line which contains an N (<= 10^100^). Output Specification: For each test case, output in one line the digits of the sum in English words. There must be one space between two consecutive words, but no extra space at the end of a line. Sample Input: 12345 Sample Output: one five 作者: CHEN, Yue 单位: PAT联盟 时间限制: 400ms 内存限制: 64MB 代码长度限制: 16KB #include

NOIP提高组历年真题题解

人盡茶涼 提交于 2020-10-28 04:59:59
2018 铺设道路 差分水题,推一下结论就好了。 #include<cstdio> #include <algorithm> using namespace std; int a[ 100005 ],d[ 100005 ],ansz,ansf; int main() { int n; scanf( " %d " ,& n); for ( int i= 1 ;i<=n;i++ ) scanf( " %d " ,&a[i]),d[i]=a[i]-a[i- 1 ]; for ( int i= 1 ;i<=n;i++ ) { if (d[i]< 0 ) ansf-= d[i]; else ansz+= d[i]; } printf( " %d\n " ,max(ansz,ansf)); return 0 ; } 货币系统 一开始以为是数学题,后来发现可以$dp$,很有意思的完全背包简单变形。 $f$数组下标存储每一个数,$true$表示已经出现,$false$表示不能被表示。 初始化$f[0]$为$true$。 #include<cstdio> #include <cstring> #include <algorithm> using namespace std; int n,a[ 205 ],f[ 25005 ],T; int main() { scanf( " %d " ,& T);

mfc CString 转 char *

戏子无情 提交于 2020-10-28 03:52:54
按照MSDN的说吗,在选用MBCS多字节字符串编码时,该方法会得到正确的字节数。此时没有问题。 For multibyte character sets (MBCS), GetLength counts each 8-bit character; that is, a lead and trail byte in one multibyte character are counted as two bytes. 但是在Unicode编码下,一旦出现中文字符,该方法就会少统计。 我试用最多的解决方法是: CString str("abc我"); DWORD le0 = str.GetLength(); // 返回4,不是想要的字节数 // 这样处理就对了。先用CStringA类转化成多字节字符串。 le0 = CStringA(str).GetLength(); 来源: oschina 链接: https://my.oschina.net/u/4156808/blog/3070269

面试常考代码

寵の児 提交于 2020-10-27 01:51:10
快排 #include<iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> #include <stack> #include <map> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> #include <stack> #include <map> #include <queue> #include <cmath> #include <list> using namespace std; typedef long long LL; typedef unsigned long long ull; #define sc1(a) scanf("%lld",&a) #define pf1(a) printf("%lld\n",a) #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 const LL INF= 1e18; const ull base = 2333 ; const int maxn=1e2+ 55 ; const int maxm=1e2+ 50 ; const int maxv=1e6+ 5 ;

算法与数据结构---6.6、斐波那契数列-记忆化递归

北慕城南 提交于 2020-10-24 12:24:46
算法与数据结构---6.6、斐波那契数列-记忆化递归 一、总结 一句话总结: 记忆化递归,就是把已经计算的中间状态保存下来,下次需要的时候就直接拿这个结果,就避免了递归中的重复计算中间状态 #include <iostream> #include <cstring> using namespace std; const int mod= 1000000007 ; int cache[ 200000 ]; int find( int n){ // 就是如果缓存中有,就直接拿缓存 // 否则计算,然后将计算的结果保存到缓存 if (cache[n]!=- 1 ) return cache[n]; else { return cache[n]=(find(n- 1 )+find(n- 2 ))% mod; } } int main(){ int n; cin >> n; memset(cache, - 1 , sizeof (cache)); cache[ 2 ]=cache[ 1 ]= 1 ; cout <<find(n)<< endl; return 0 ; } 二、斐波那契数列 博客对应课程的视频位置:6.6、斐波那契数列-记忆化递归 https://www.fanrenyi.com/video/27/278 1、题目描述 问题描述: 满足F1=F2=1,F(n)=F(n-1)+F

ICPC Pacific Northwest Regional Contest 2016 C. Buggy Robot

十年热恋 提交于 2020-10-09 05:12:05
Buggy Robot    思路:dp[inx][x][y],表示用了前inx个指令后的最小费用。 对于一个指令,我们可以选择不走或者走,其他的我们可以添加四个方向的指令与使用过指令后的dp来比较。 1 #include <iostream> 2 #include <algorithm> 3 #include <cstdio> 4 #include <queue> 5 #include <cstring> 6 7 using namespace std; 8 9 const int N = 60 ; 10 const int INF = 1e9; 11 int mv_x[] = { 1 , - 1 , 0 , 0 }; 12 int mv_y[] = { 0 , 0 , - 1 , 1 }; 13 char mp[N][N]; 14 int dp[N][N][N]; 15 char str[N]; 16 int n, m; 17 18 struct node 19 { 20 int inx, x, y; 21 }R, E; 22 23 bool inline check( int x, int y) 24 { 25 return x >= 0 && x < n && y >= 0 && y < m; 26 } 27 28 void bfs() 29 { 30 for ( int

C++实现修改windows窗体背景颜色小工具

独自空忆成欢 提交于 2020-10-01 10:03:51
C++实现修改windows窗体背景颜色小工具 C++实现修改windows窗体背景颜色小工具。 主要思路是: 修改widows注册表,将window窗体背景色修改为淡绿色("199 237 204")。 刷新windows窗体,让刷新窗体背景色当即生效。 示例如下: 程序入口点代码 ```c++ // 01_backgroundcolorregchangeTest.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> #include <Windows.h> #include <tchar.h> using namespace std; TCHAR g_tszRegCareValue[2][16] = {_T("255 255 255"), _T("199 237 204")}; //注册表默认值 保护色值 DWORD g_szdwColors[2] = {RGB(255, 255, 255), RGB(199, 237, 204)}; //颜色 白色和 豆沙绿 int g_iElements[1] = {COLOR_WINDOW}; //修改颜色的类型 这里是窗口 void CreateReg(HKEY Root,LPCTSTR szSubKey,LPCTSTR valueName,LPCTSTR