- 博客(33)
- 资源 (4)
- 收藏
- 关注
原创 【C++学习笔记】wchar_t、WCHAR、TCHAR数据类型,宏L、TEXT、_TEXT、_T
一、在字符串前加一个L作用: 如 L"我的字符串" 表示将ANSI字符串转换成unicode的字符串,就是每个字符占用两个字节。 strlen("asd") = 3; strlen(L"asd") = 6; 二、 _T宏可以把一个引号引起来的字符串,根据你的环境设置,使得编译器会根据编译目标环境选择合适的(Unicode还是ANSI)字符处理方式
2013-08-27 14:31:47 1274
原创 【C++学习笔记】文件操作编程基础
需要用到的几个函数//*********************************************************************************************************************HANDLE CreateFile(LPCTSTR lpFileName, // file
2013-08-27 11:08:53 645
原创 【C++学习笔记】返回桌面等特系统殊路径地址 —> SHGetSpecialFolderPath
获得桌面路径地址//头文件#include //函数原型BOOL SHGetSpecialFolderPath(HWND hwndOwner, //可用GetDesktopWindow API取一个窗口句柄或直接传NULL. LPTSTR lpszPath, //返回路径的缓冲区 int nFolder, //标识代号 BOOL fCr
2013-08-27 00:24:03 2574
原创 【C++学习笔记】C++控制台程序隐藏界面运行的方法
大家都知道,当编写一个win32 console application时,当运行此类程序的时候默认情况下会有一个类似DOS窗口的console窗口,但是有的时候我们只想在程序中运行一段功能代码,不希望显示这个console窗口,让代码执行完毕之后程序自动退出。具体实现只要在开头加上下面一行宏就可以了。#pragma comment(linker, "/subsystem:\"windows\
2013-08-26 23:41:34 2235
原创 【C++学习笔记】简单的多线程程序(摘自孙鑫C++教学视频)
#include "stdafx.h"#include #include using namespace std;DWORD WINAPI Fun1Proc(LPVOID lpParameter);//thread dataDWORD WINAPI Fun2Proc(LPVOID lpParameter);//thread dataint index=0;int tickets=
2013-08-22 19:38:18 919
原创 【HDOJ】1862 -> EXCEL排序
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1862心得: 用sort比较函数对结构体进行排序。代码:#include #include using namespace std;typedef struct {char ID[7]; char Name[9]; short Score;}STUDE
2013-08-20 14:50:02 595
原创 【HDOJ】1708 -> Fibonacci String
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1708心得: 用map统计相同字符出现的次数比较方便,另外此题格式不严谨,最后多了一行回车,考虑到你就PE了。代码:#include #include using namespace std;int main(){ int t,i,k; __int
2013-08-20 11:23:14 694
原创 【HDOJ】1405 -> The Last Practice
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1405心得: 题目输出格式有问题,每行最后一个数多输出了一个空格。代码:#include #include int main(){ int n,i,j,a[20][2],t=1; while(~scanf("%d",&n) && n>0){
2013-08-18 23:34:22 752
原创 【HDOJ】1395 -> 2^x mod n = 1
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1395心得: 欧拉定理: a^phi(m) ≡1(mod m),phi(m)为欧拉函数,表示比m小且与m互质的正整数个数,当m为质数时,phi(m)=m-1。即为费马定理。本题中:1、当n为1时无解。 2、当n为偶数时,2^x也为偶数,所以2^x不可能和n关于奇数1同
2013-08-18 21:33:56 772
原创 【HDOJ】1335 -> Basically Speaking
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1335心得: 先将原数转为十进制数,再利用itoa函数或strtol函数转化为其他进制数。注意,itoa转化后的字符为小写,可以用toupper函数将小写转化为大写。代码:#include #include #include using namespa
2013-08-18 10:56:59 674
原创 【HDIJ】1266 -> Reverse Number
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1266心得: 人人都会做的题,贴个简单点代码,用reverse反转字符串,find_last_not_of('0')返回字符串第一个不是0的位置。代码:#include #include #include using namespace std;in
2013-08-17 16:31:07 784
原创 【HDOJ】1236 -> 排名
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1236心得: 被WA四次的题,主要难点在于比较函数的写法上。如果成绩不同则按成绩降序排,成绩相同则按学号升序排。代码:#include #include using namespace std;typedef struct{char ID[21];in
2013-08-17 09:07:54 868
原创 【HDOJ】1235 -> 统计同成绩学生人数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1235心得: 个人觉得这题用multiset解代码最简洁,若果有更简洁的,交流交流哈。代码:#include #include using namespace std;int main(){ int n,x; multiset ms; while
2013-08-16 21:59:54 464
原创 【HDOJ】1234 -> 开门人和关门人
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1234心得: 时间换算成秒比较大小,使用结构体,memcpy内存拷贝。代码:#include using namespace std;typedef struct {char ID[20];int s0;int s1;} Data;int main()
2013-08-16 21:45:16 689
原创 【HDOJ】1205 -> 吃糖果
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1205心得: 代码本身没有难度,只要能够想出sum-max>=max-1本题就不难了。因为其他糖果都能插进最多的糖果的缝隙中,要把最多的糖果分隔开,最少需要max-1个其他糖果。另外,测试数据过多时尽量采用scanf函数。代码:#include int m
2013-08-16 19:46:46 682
原创 【HDOJ】1201 -> 18岁生日
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1201心得: 每年当做365天,每过一次闰年2月29日(出生时不包括,18岁生日时包括)总天数就+1。代码:#include using namespace std;const int NUM_OF_BIRTHDAY=18;bool LeepYear(
2013-08-16 15:49:20 661
原创 【HDOJ】1197 -> Specialized Four-Digit Numbers
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1197心得: 利用映射表转换字符。代码:#include #include using namespace std;int main(){ char base10[20],base12[20],base16[20]; int i,j,sum10,s
2013-08-16 14:34:15 666
原创 【HDOJ】1196 -> Lowest Bit
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1196心得: itoa(int value, char *string, int radix)对于进制转换非常管用,参见http://baike.baidu.com/view/982195.htm代码:#include #include using
2013-08-16 12:45:55 555
原创 【HDOJ】1164 -> Eddy's research I
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1164心得: 做一个2~n的循环,取出i,筛掉i的倍数,当n不包含因子i的时候i++。代码:#includeusing namespace std;int main(){ int n,i,j,a[100]; while(cin>>n){ for(
2013-08-16 11:54:10 511
原创 【HDOJ】1163 -> Eddy's digital Roots
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1163心得: 九余数定理:一个数的九余数等于这个数各位数之和的九余数。换而言之,就是一个数每mod9一次,就相当于这个数的各位数相加再mod9一次。再换而言之,就是一个数的各位数之和mod9的值恒等于它本身mod9的值,并且与它本身mod9多少次没有关系!
2013-08-16 00:50:35 599
原创 【HDOJ】1106 -> 排序
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1106心得: sscanf函数可以从字符串格式化写入相符类型的数据,功能十分强大。参见http://baike.baidu.com/view/1364018.htm代码:#include #include #include using namespac
2013-08-15 23:16:27 887
原创 【HDOJ】1097 -> A hard puzzle
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1097心得: 个位数相乘公共周期为4,。简单题就要一次AC!代码:#include using namespace std;int main(){ int t[10][5]= {{0,0,0,0},{1,1,1,1},{6,2,4,8},{1,3
2013-08-15 20:37:56 560
原创 【HDOJ】1070 -> Milk
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1070心得: 最大的体会就是这个叫做Ignatius的高帅富牛奶少于200ml就倒掉,5天喝不完的牛奶还要买。勤俭节约的孩纸不要学习他哦!代码:#include using namespace std;typedef struct{ char bra
2013-08-15 13:41:44 729
原创 【HDOJ】1005 -> Number Sequence
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005心得: 在OJ平台、博客等很多地方看到有人称此题的循环节为48,并得到了AC,可能是测试数据覆盖范围过小的缘故,我只能说你们得逞了。下图是某网友的AC算法:#includeint main(){ long a,b,n,i,f[100]; whil
2013-08-15 07:49:50 659
原创 【HDOJ】1058 -> Humble Numbers
心得: DP问题,a[i]=min{ a[j]*2 , a[k]*3 , a[m]*5 , a[n]*7 }。如果认为本题的重点是打表的话你就错了,英语序数词坑了无数人,所以下面我就不厌其烦把小学英语知识点再回顾一遍。末位是1但后两位不是11的+st末位是2但后两位不是12的+nd末位是3但后两位不是13的+rd代码:#in
2013-08-14 23:29:45 570
原创 【HDOJ】1056 -> HangOver
心得: 二分查找代码:#include using namespace std;int bsearch(int l,int r,double k,double a[]){ //二分查找 int m; while(l<=r){ m=(l+r)/2; if(k>a[m-1] && k<=a[m]) break; else if(k>a[m])
2013-08-14 21:12:34 566
原创 【HDOJ】1048 -> The Hardest Problem Ever
心得: 可以用映射表,也通过两个字符数组相互替换。(以下代码采用后者方法)代码:#include using namespace std;int main(){ char s1[30]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char s2[30]="VWXYZABCDEFGHIJKLMNOPQRSTU"; char c[1000]
2013-08-14 12:54:00 628
原创 【HDOJ】1032 -> The 3n + 1 problem
心得: 输入范围【a,b】注意判断是否满足b>=a,返回值也要保证a在b前。代码:#include using namespace std; int f(int n){ int sum=1; while(n!=1){ if(n%2==1) n=3*n+1; else n/=2; sum++; } return sum;}
2013-08-13 22:01:26 586
原创 【HDOJ】1029 -> Ignatius and the Princess IV
心得: 通常可以用a[index]=k表示数字index重复的次数为k。代码:#include using namespace std; const int MAX=500000;int a[MAX];int main(){ int n,x,i,id; while(cin>>n){ memset(a,0,sizeof(a)); fo
2013-08-13 21:04:10 712
原创 【HDOJ】1028 -> Ignatius and the Princess III
心得: 利用母函数,求(1+x+x^2+...+x^n)*(1+x^2+x^4+...+x^2(n/2))*.......*(1+x^n)展开式x^n项的系数即可。代码:#include using namespace std; const int LEN=1000;int main(){ int n,i,j,k,temp; int c1[LEN],
2013-08-13 17:57:15 654
原创 【HDOJ】1019 -> Least Common Multiple
心得: n个数的最小公倍数,两两求即可。代码:#include using namespace std;int gcd(int a,int b){ if(!b) return a; else return gcd(b,a%b);}int main(){ int N,n,x,y; cin>>N; while(N--){ ci
2013-08-13 10:50:05 476
原创 【HDOJ】1014 -> Uniform Generator
心得: 本题可转化为证明step与mod互质,因为若step与mod不互质,则seed[gcd(step,mod)]=0。代码:#include using namespace std;int gcd(int a,int b){ if(!b) return a; return gcd(b,a%b);}int main(){
2013-08-12 21:49:57 586
原创 【HDOJ】题目分类
基础题:1000、1001、1004、1005、1008、1012、1013、1014、1017、1019、1021、1028、1029、1032、1037、1040、1048、1056、1058、1061、1070、1076、1089、1090、1091、1092、1093、1094、1095、1096、1097、1098、1106、1108、1157、1163、1164、1170、1194、1
2013-08-12 18:25:57 886
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人