自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

AI蜗牛之家

北航烟酒僧~ 腾讯自然语言处理算法工程师~

  • 博客(41)
  • 资源 (4)
  • 收藏
  • 关注

原创 (三种遍历二叉树操作实例)(待解决)A - Tree Recovery(9.3.1)

#include#includeusing namespace std;char pre[27],mid[27];int n = -1;int count=0 ;char last[27];void make_tree(int i, int j){  int k;  if(i > j)       return;  n++;  for(k = i

2014-07-31 11:21:13 1280

原创 scanf()返回值

关于scanf返回值飞鱼_00700810级 被浏览166次 2013.09.10 检举void main(){int a,b,c;c=scanf("%d %d",&a,&b);printf("%d",c);}为什么我输入a 1 , c的值就为0,输入1 a,c的值为1scanf返回接收到的变量值的

2014-07-31 10:39:04 887

原创 (二叉树递归)A - Tree Grafting(9.1.1)

#include #include using namespace std;string s;int i,n=0,height1,height2;void work(int level1,int level2)//第一个变量是用来测改变前的,第二个是用来测改变后的{ int tempson=0; while (s[i]=='d') {  i++;   t

2014-07-30 19:07:14 954

原创 strlen() sizeof() lenth()函数的返回值问题

//string a="abcd";//a.length()求出来的值 能与 -1 比较吗?//a.size()求出来的值 能与 -1 比较吗?#include#includeusing namespace std;int main(){/*string a="abcd";//--------------------------coutc

2014-07-30 09:04:24 3693

原创 Binary Tree

POJ 2499                          Binary TreeTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 6004 Accepted: 2781DescriptionBackground Binary trees are

2014-07-29 20:13:01 699

原创 (并查集..含小总结)A - Hire and Fire(8.1.2)

#include#include #includeusing namespace std;const int N=1010;bool check[N];int n,d;struct node  {   int fa;   int x, y;   }p[N];int find(int w){ if(p[w].fa==0)  return w

2014-07-29 10:28:44 1001

原创 (超简单并查集)POJ2524 Ubiquitous Religions(8.4.4)

#include#include #includeusing namespace std;int set[50005];int set_find(int x){ if(set[x]  return x; return set[x]=set_find(set[x]);}int main (){ int n,i,a,b,x=0,m,count;

2014-07-28 18:33:07 805

原创 (并查集)B - Friends(8.4.1)

简单的压缩查找,没有什么技术含量#include#include #includeusing namespace std;int set[30005];int set_find(int x){ if(set[x]  return x; return set[x]=set_find(set[x]);} int main (){ int n,

2014-07-28 16:26:13 973

原创 (待整理)B - Cube Stacking(8.2.2)

本思路简单,但是没有路径压缩和优化 #include#include using namespace std;int count ;int son[30005],fa[30005]; int find(int w){ if(fa[w]==0)  return w; else {  count++; return   find(fa[w]);

2014-07-28 10:48:09 981

原创 (并查集 )A - Find them, Catch them(8.2.1)

#include#include#includeusing namespace std;const int maxn=100000 +5;int n,m;int set[maxn +maxn];int set_find(int d){ if(set[d]  return d; return set[d]=set_find(set[d]);//路径压缩并查

2014-07-27 11:32:47 960

原创 Compile Error

1.在提交时如果出现这样的情况:

2014-07-27 11:09:47 1535

原创 c++ 银行管理系统及报告

#include#includeusing namespace std;class information{public :    string num ;//账号 string name;//用户名    string key;//密码    string ID;//身份证号    string tel;//电话号码    double money;/

2014-07-27 10:59:14 8801 8

原创 (Vedctor经典)A - Nearest Common Ancestors(8.1.1)

#include#include #include using namespace std;const int N=10000;vector a[N];//儿子表int  f[N] ,r[N];//f[N]存储父节点,r[N]为层数void DFS (int u,int dep)//对当前的节点父节点进行初始化{ r[u]=dep; vector ::it

2014-07-26 16:38:15 1083

原创 C++ map用法

.find()函数// map::find#include #include using namespace std;int main (){  std::map mymap;  std::map::iterator it;  mymap['a']=50;  mymap['b']=100;  mymap['c']=150;  mymap['d']=2

2014-07-26 10:52:11 2477

原创 (约瑟夫应用)5.4.1 Roman Roulette

这道题和#include#include using namespace std;int main(){ int m,n,p=0,q,i,a[105],count,x; while(cin>>m>>n&&m!=0&&n!=0) {  for(i=1;i   a[i]=i;    int ex=m;  for(x=1;x  {         

2014-07-24 12:26:01 1666

转载 部分题集代码

#include    #include #include    #include    #include    using namespace std;  #define maxn 2010     void makeset(int f[], int a)  {      f[a]=a;  }  int find(int f[], int a) 

2014-07-23 17:56:00 712

转载 随机生成数

如何用随机数生成0到n之间的m个不重复的数1、最直接的方法就是先随机生成一个0到n之间的数,判断这个数是否已被选上,如果以前没选过,则选上,如果以前已选,则丢弃[cpp] view plaincopyprint?void common(int n,int m)  {      int * randnum=(int *)malloc(n*sizeof(int));

2014-07-23 17:54:08 1122

转载 string 与char* char[]之间的转换 .

1、首先必须了解,string可以被看成是以字符为元素的一种容器。字符构成序列(字符串)。有时候在字符序列中进行遍历,标准的string类提供了STL容器接口。具有一些成员函数比如begin()、end(),迭代器可以根据他们进行定位。注意,与char*不同的是,string不一定以NULL('\0')结束。string长度可以根据length()得到,string可以根据下标访问。所以,

2014-07-23 17:18:44 855

原创 (分治思想)(归并排序)C - Ultra-QuickSort(7.2.2)

#include #include #define MAX 500001int n, a[MAX], t[MAX];__int64 sum;/* 归并 */void Merge(int l, int m, int r){ //p指向输出区间    int p = 0; //i、j指向2个输入区间    int i = l, j = m + 1;//2个输

2014-07-23 15:18:50 955

转载 如何取出 Map中key和value的值

你是否已经对每次从Map中取得关键字然后再取得相应的值感觉厌倦?使用Map.Entry类,你可以得到在同一时间得到所有的信息。标准的Map访问方法如下: Set keys = map.keySet( ); if(keys != null) { Iterator iterator = keys.iterator( ); while(iterator.hasNext( )) { Object key

2014-07-22 17:56:11 1450

转载 C++ STL 中 map 容器的说明和使用技巧 .

Map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据 处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时候,在编程上提供快速通道。这里说下map内部数据的组织,map内部自建一颗红黑树(一 种非严格意义上的平衡二叉树),这颗树具有对数据自动排序的功能,所以在map内部所有的数据都是有序的,后边我们会见识

2014-07-22 17:52:20 874

原创 (经典map)A - Hardwood Species(7.1.1)(利用STL中自带的排序功能编程的实验范例)

#include#include #include #include #include using namespace std;typedef maprecord;record h;string s;int n;int main(){ n=0; while(getline(cin,s))/////默认为文件结束才输出结果 {  n++;

2014-07-22 17:00:12 921

原创 Babelfish(6.1.2)(sort结构体排序)(sscanf()基本使用方法)(二分法)

#include#include#include #include using namespace std;struct aa{ char  a[20]; char b[20];}str[100005];bool cmp(aa x,aa y)///////配合sort函数使用---比较函数{ if(strcmp(x.b,y.b)  return

2014-07-22 14:20:19 1110

原创 C++ 排序算法

经典排序算法总结(代码)·冒泡法·快速排序·插入排序·希尔(shell)排序·选择排序·堆排序·归并排序 附:排序算法原理:http://zh.wikipedia.org/wiki/Category:%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95flash演示:http://www.tyut.edu.cn/keche

2014-07-22 10:04:01 1352

转载 sscanf函数用法详解

sscanf函数用法详解作者: 来源:   名称:   sscanf() - 从一个字符串中读进与指定格式相符的数据.   函数原型:   Int sscanf( string str, string fmt, mixed var1, mixed var2 ... );   int scanf( const char *format [,argument]... )

2014-07-21 19:48:30 1103

原创 POJ 1363 5.2.1 Rails(出栈入栈经典)

#include#includeusing namespace std;const int maxn=1000+10;int main(){ int n,p[maxn];  cin>>n; while(n) {  int x,max=0;  cin>>x;//输入一行中的某一个  while(x)  {   memset(p,0,size

2014-07-21 16:24:24 1042

原创 (约瑟夫问题延伸)5.1.2The Dole Queue

In a serious attempt to downsize (reduce) the dole queue, The New National Green Labour Rhinoceros Party has decided on the following strategy. Every day all dole applicants will be placed in a large

2014-07-21 12:02:38 1016

原创 A - Oulipo(KMP算法经典)

#include#include #include int match (char w[],char s[],int next[])//统计w[]在s[]中出现的次数{   int cnt=0;  //w[]在s[]中的频率初始化 int slen=strlen(s); int wlen=strlen(w); int p=0,cur=0;//w s初始化 whi

2014-07-20 19:53:52 2090 1

原创 KMP算法

相信很多人(包括自己)初识KMP算法的时候始终是丈二和尚摸不着头脑,要么完全不知所云,要么看不懂书上的解释,要么自己觉得好像心里了解KMP算法的意思,却说不出个究竟,所谓知其然不知其所以然是也。     经过七八个小时地仔细研究,终于感觉自己能说出其所以然了,又觉得数据结构书上写得过于简洁,不易于初学者接受,于是决定把自己的理解拿出来与大家分享,希望能抛砖引玉,这便是Bill写这篇文章想要得到

2014-07-20 19:09:50 1516

原创 字符串库函数

string定义:a) string s; //生成一个空字符串sstring a="eholldfs";   a="dfgdfg";   cin>>a;b) string s(str) //拷贝构造函数生成str的复制品c) string s(str,stridx) //将字符串str内"始于位置stridx"的部分当作字符串的初值d) s

2014-07-20 17:40:30 1605

原创 D - Blue Jeans(4.6.1)

DescriptionThe Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of contributors to map how the Earth w

2014-07-20 17:28:08 878

原创 4.3.2 C - Modular multiplication of polynomials(简单线性表)

DescriptionConsider polynomials whose coefficients are 0 and 1. Addition of two polynomials is achieved by 'adding' the coefficients for the corresponding powers in the polynomials. The addition o

2014-07-20 09:49:48 1369

原创 4.2.1 B - Adding Reversed Numbers(高精度运算)

#include #include #include        //string类型lengthusing namespace std;int a[1000]={0},b[1000]={0},c[1000]={0};int zhuanhuan(string str,bool boo){ int n,i,l=0, w=0;; n=str.length(); i

2014-07-18 14:38:39 1021

原创 4.1.1 A - Calendar(简单线性表)(日期查找)(数组应用)

#include #include #include using namespace std;int  wee=0,n,year=2000,month=1,day=1,x;char week[][10]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday","Friday","Saturday"};bool isle

2014-07-18 08:43:22 1124

原创 C - Fractal(3.4.1)

对这样的递归图形问题,只是简单的将其写出函数即找出规律,然后找出边界,然后写成递归就行了有点逗比的是将题目中的-写成了_,wr了好多次!!!!     本题使用函数pow(a,b)即a的b次方

2014-07-17 17:34:19 833

原创 A - Red and Black(3.2.1)(小递归)

DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent til

2014-07-17 12:44:05 1082

原创 排序(sort qsort)

sort() 函数表:函数名 功能描述 sort 对给定区间所有元素进行排序 stable_sort 对给定区间所有元素进行稳定排序 partial_sort 对给定区间所有元素部分排序 partial_sort_copy 对给定区间复制并排序 nth_element 找出给定区间的某个位置对应的元素 is_sorted 判断一个区间是否已经排好序 partition 使得符合某个条件的元素放在前面 stable_par

2014-07-17 09:06:52 1001

原创 排序

#include #include #include #include using namespace std;int main(){ int x,d,i,j,a[1500],n,w; scanf("%d",n); for(w=1;w {  scanf("%d,%d",x,d);        int all=1;  for(i=0;i  s

2014-07-17 08:54:22 1314

转载 动态规划入门教程

很特别的一个动态规划入门教程很特别的一个动态规划入门教程今天在网上看到一个讲动态规划的文章,是以01背包为例的,这文章和书上的讲解非常不一样,令我眼前一亮,于是转载一下下~~~(说明一下,本人非常痛恨教材公式定理漫天飞,实际的讲解却讲得非常枯涩难懂,这种中国式的教育已经延绵了几千年了,现在中国的教材还是这个样子,讲清楚些明白些就那么难么?高中有个老师讲的一句话一

2014-07-17 08:46:08 1048

原创 第二章 I - The 3n + 1 problem(2.4.2)

这是一道很坑爹的题,一定注意输入的两个数的大小,并且不能简单的交换,因为在最后的输出的时候还需要将原来的数按照原来的顺序和大小,这就是为什么还得开辟两个值得原因DescriptionProblems in Computer Science are often classified as belonging to a certain class of problems (e.g.

2014-07-16 15:05:02 782

Redis-x64-3.2.100.msi

Redis-x64-3.2.100.msi,因为官网的速度实在是太低了,所以下载下来共享,不过现在最低需要2积分,没法免费了,是在抱歉,若需要留言也可

2017-10-14

STL整理总结

C++的基本库函数STL

2017-04-24

坦克大战游戏,支持声音,配置等

自己写的坦克大战,包括声音等特效,能够对游戏进行坦克数目、地图等进行设置,代码大约1200-1300行,可在此基础上进行深度开发,是对初学者并有部分Java基础的一个很好的锻炼机会,代码由本人自主开发,较为实用。当然也可以作为大作业使用

2015-03-14

C++ API

包含C++以及C语言的库函数,在学习和使用时便于查找和理解库函数

2015-01-24

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除