Fork me on GitHub

上一页 1 ··· 3 4 5 6 7
  2013年1月31日
摘要: C 二维数组动态分配和释放(1)已知第二维Code-1char (*a)[N];//指向数组的指针a = (char (*)[N])malloc(sizeof(char *) * m);printf("%d\n", sizeof(a));//4,指针printf("%d\n", sizeof(a[0]));//N,一维数组free(a); (2)已知第一维Code-2char* a[M];//指针的数组int i;for(i=0; i<M; i++)a[i] = (char *)malloc(sizeof(char) * n);printf(&qu 阅读全文
posted @ 2013-01-31 15:07 huashiyiqike 阅读(16478) 评论(0) 推荐(0) 编辑
  2013年1月28日
摘要: VC6.0调试大全VC调试方法大全一、调试基础调试快捷键F5:开始调试Shift+F5:停止调试F10:调试到下一句,这里是单步跟踪F11:调试到下一句,跟进函数内部Shift+F11:从当前函数中跳出Ctrl+F10:调试到光标所在位置F9:设置(取消)断点Alt+F9:高级断点设置跟踪调试1、尽量使用快捷键时行调试2、观察调试信息3、高级中断设置异常调试重试->取消->调试函数堆栈,用variables或者callstack窗口Release调试1、经常测试你的Debug和Release版本2、不要移除调试代码,如用ASSERT,TRACE等。3、初始化变量,特别是全局变量,m 阅读全文
posted @ 2013-01-28 16:27 huashiyiqike 阅读(513) 评论(0) 推荐(0) 编辑
摘要: 题目89:Prime ring problem时间限制:2 秒内存限制:128 兆特殊判题:否提交:54解决:12题目描述:A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Note: the number of first circle should always be 1.输入:n (1 阅读全文
posted @ 2013-01-28 14:48 huashiyiqike 阅读(183) 评论(0) 推荐(0) 编辑
  2013年1月27日
摘要: Hanoi Tower 经典递归题目之汉诺塔的简单解析2011-11-14Hashtable和HashMap采取的hash/rehash算法都概略一样,所以机能不会有很大年夜的不合。恶徒也熟悉真谛,只是他见了真谛就胆怯。 当然、这是一个经典的递归题目~ 想必来看这篇博文的同窗对汉诺塔应当不会陌生了吧,只有受过教导的诚恳至心的人才是有趣味的人,也只有他们才是社会所须要的。如许的人越多,天堂来到人世也就越快。 写这篇博还是有初志的: 之前学数据布局的时辰本身看书、也上彀上查了很多材料,材料都斗劲散、并且描述的不是很清楚,对于当时方才接触算法的我,要完全懂得还是有必然难度。今天正好有时候就收... 阅读全文
posted @ 2013-01-27 19:27 huashiyiqike 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 题目106:单词替换时间限制:1 秒内存限制:32 兆特殊判题:否提交:1111解决:321题目描述:输入一个字符串,以回车结束(字符串长度<=100)。该字符串由若干个单词组成,单词之间用一个空格隔开,所有单词区分大小写。现需要将其中的某个单词替换成另一个单词,并输出替换之后的字符串。输入:多组数据。每组数据输入包括3行,第1行是包含多个单词的字符串 s,第2行是待替换的单词a,(长度<=100)第3行是a将被替换的单词b。(长度<=100)s, a, b 最前面和最后面都没有空格.输出:每个测试数据输出只有 1 行,将s中所有单词a替换成b之后的字符串。样例输入:You 阅读全文
posted @ 2013-01-27 15:09 huashiyiqike 阅读(438) 评论(0) 推荐(0) 编辑
摘要: C++中string的成员函数string类的构造函数:string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化此外,string类还支持默认构造函数和复制构造函数,如string s1;string s2="hello";都是正确的写法。当构造的string太长而无法表达时会抛出length_error异常string类的字符操作:const char &operator[](int n)const;const char &at(int n)const;char &ope 阅读全文
posted @ 2013-01-27 13:50 huashiyiqike 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 题目104:字符串的查找删除时间限制:1 秒内存限制:32 兆特殊判题:否提交:1439解决:476题目描述:给定一个短字符串(不含空格),再给定若干字符串,在这些字符串中删除所含有的短字符串。输入:输入只有1组数据。输入一个短字符串(不含空格),再输入若干字符串直到文件结束为止。输出:删除输入的短字符串(不区分大小写)并去掉空格,输出。样例输入:in#include int main(){printf(" Hi ");}样例输出:#cludetma(){prtf("Hi");}提示:注:将字符串中的In、IN、iN、in删除。#include<c 阅读全文
posted @ 2013-01-27 13:42 huashiyiqike 阅读(408) 评论(0) 推荐(0) 编辑
摘要: #include<cstdio>#include<cstdlib>#include<cmath>#include<cstring>#include<string>#include<algorithm>#include<iostream>#include<sstream>using namespace std;int main(){ stringstream a;int n; char num[10000]="32333"; string b=num; printf("% 阅读全文
posted @ 2013-01-27 11:52 huashiyiqike 阅读(98) 评论(0) 推荐(0) 编辑
摘要: #include<cstdio>#include<cstdlib>#include<math.h>#include"string.h"bool zero(long long *a,int len){ bool zero=true; for(int i=0;i<len;i++) if(a[i]!=0) zero=false; return zero;}int main(){ //freopen("in.txt","r",stdin); int i,j,k,max,a,b,tenleft,len; 阅读全文
posted @ 2013-01-27 10:36 huashiyiqike 阅读(219) 评论(0) 推荐(0) 编辑
  2013年1月24日
摘要: 问题描述:(具体见http://acm.hdu.edu.cn/showproblem.php?pid=1081)给定一个n*n(0<n<=100)的矩阵,请找到此矩阵的一个子矩阵,并且此子矩阵的各个元素的和最大,输出这个最大的值。Example:0 -2 -7 09 2 -6 2-4 1 -4 1-1 8 0 -2其中左上角的子矩阵:9 2-4 1-1 8此子矩阵的值为9+2+(-4)+1+(-1)+8=15。我们首先想到的方法就是穷举一个矩阵的所有子矩阵,然而一个n*n的矩阵的子矩阵的个数当n比较大时时一个很大的数字 O(n^2*n^2),显然此方法不可行。怎么使得问题的复杂度降 阅读全文
posted @ 2013-01-24 11:51 huashiyiqike 阅读(364) 评论(0) 推荐(0) 编辑
  2013年1月23日
摘要: scanf读入非空格分隔的字符串和整形的混合类型问题今天在网上看到一个网友提问这样一个问题:C语言输入字符串和数字时如何用逗号隔开,比如输入zhang1,90要求把zhang1赋给一个字符数组把90付给一个INT的变量。刚开始只想到如果用scanf("%s,%d",name,&age); 这种方式肯定会出现问题,输入的数据肯定都会被赋值给字符串,整形数据肯定会是个随机数,因此给网友回答时说不要将字符串写在前面,来避免该问题。后来网友说肯定能实现,因此在网上查了一些资料,终于将该问题解决,如下:scanf("%[^,],%d",name,& 阅读全文
posted @ 2013-01-23 17:05 huashiyiqike 阅读(4765) 评论(0) 推荐(2) 编辑
摘要: 1、字符串转数值#include <stdlib.h>#include <stdio.h>void main( void ){ char a[100]="0023200"; long b=strtol(a,NULL,10); printf("%ld",b);} 阅读全文
posted @ 2013-01-23 13:40 huashiyiqike 阅读(162) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<cstdio>#include<fstream>#include<cstring>#include<algorithm>bool cmp(int a,int b){ return a<b?0:1;}int main(){ freopen("in.txt","r",stdin); bool flag,end; char ser[1000][16],ip[5000][16];int begin,m,n,i,j,count,num;// 阅读全文
posted @ 2013-01-23 09:34 huashiyiqike 阅读(209) 评论(0) 推荐(0) 编辑
  2013年1月22日
摘要: 题目1011:最大连续子序列时间限制:1 秒内存限制:32 兆特殊判题:否提交:1724解决:856题目描述: 给定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ Ni, Ni+1, ..., Nj },其中 1 <= i <= j <= K。最大连续子序列是所有连续子序列中元素和最大的一个,例如给定序列{ -2, 11, -4, 13, -5, -2 },其最大连续子序列为{ 11, -4, 13 },最大和为20。现在增加一个要求,即还需要输出该子序列的第一个和最后一个元素。输入: 测试输入包含若干测试用例,每个测试用例占2行,第1行给出 阅读全文
posted @ 2013-01-22 15:11 huashiyiqike 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 题目1152:点菜问题时间限制:1 秒内存限制:32 兆特殊判题:否提交:371解决:170题目描述: 北大网络实验室经常有活动需要叫外买,但是每次叫外买的报销经费的总额最大为C元,有N种菜可以点,经过长时间的点菜,网络实验室对于每种菜i都有一个量化的评价分数(表示这个菜可口程度),为Vi,每种菜的价格为Pi, 问如何选择各种菜,使得在报销额度范围内能使点到的菜的总评价分数最大。 注意:由于需要营养多样化,每种菜只能点一次。输入: 输入的第一行有两个整数C(1 <= C <= 1000)和N(1 <= N <= 100),C代表总共能够报销的额度,N>代表能点菜的 阅读全文
posted @ 2013-01-22 15:09 huashiyiqike 阅读(160) 评论(0) 推荐(0) 编辑
  2013年1月20日
摘要: http://ac.jobdu.com/problem.php?pid=1149题目描述:给出一个01字符串(长度不超过100),求其每一个子串出现的次数。输入:输入包含多行,每行一个字符串。输出:对每个字符串,输出它所有出现次数在1次以上的子串和这个子串出现的次数,输出按字典序排序。样例输入:10101样例输出:0 201 21 310 2101 2#include <stdio.h>#include <string.h>#include <stdlib.h>char arr[10000][101];int cmp(const void * a,const 阅读全文
posted @ 2013-01-20 19:09 huashiyiqike 阅读(176) 评论(0) 推荐(0) 编辑
  2013年1月15日
摘要: #include <string.h> #include <stdio.h> #include <stdlib.h>#include<iostream>#include<math.h>using namespace std;char num[10][10]={"zero","one","two","three","four","five","six","seven"," 阅读全文
posted @ 2013-01-15 21:54 huashiyiqike 阅读(151) 评论(0) 推荐(0) 编辑
  2013年1月14日
摘要: DescriptionGiven an×nmatrixAand a positive integerk, find the sumS=A+A2+A3+ … +Ak.InputThe input contains exactly one test case. The first line of input contains three positive integersn(n≤ 30),k(k≤ 109) andm(m< 104). Then follownlines each containingnnonnegative integers below 32,768, givin 阅读全文
posted @ 2013-01-14 20:58 huashiyiqike 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 题目描述:给定a0,a1,以及an=p*a(n-1) + q*a(n-2)中的p,q。这里n >= 2。 求第k个数对10000的模。输入:输入包括5个整数:a0、a1、p、q、k。输出:第k个数a(k)对10000的模。样例输入:20 1 1 14 5样例输出:8359p q 矩阵二维!用一维数组实现 三维则更多#include "stdio.h"#include "stdlib.h"#include"string.h"#include "algorithm"void mul(__int64 *a,__in 阅读全文
posted @ 2013-01-14 16:20 huashiyiqike 阅读(340) 评论(0) 推荐(0) 编辑
  2013年1月13日
摘要: #include "stdio.h"#include "stdlib.h"#include "algorithm"int main(){ int i,j,temp,m,n,flag; long long aim; long long **a; a=(long long**)malloc(sizeof(long long*)*1000); for(i=0;i<1000;i++) {a[i]=(long long*)malloc(sizeof(long long)*1000);} while(scanf("%d %d&qu 阅读全文
posted @ 2013-01-13 21:12 huashiyiqike 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 做ACM题的时候,排序是一种经常要用到的操作。如果每次都自己写个冒泡之类的O(n^2)排序,不但程序容易超时,而且浪费宝贵的比赛时间,还很有可能写错。STL里面有个sort函数,可以直接对数组排序,复杂度为n*log2(n)。使用这个函数,需要包含头文件。 这个函数可以传两个参数或三个参数。第一个参数是要排序的区间首地址,第二个参数是区间尾地址的下一地址。也就是说,排序的区间是[a,b)。简单来说,有一个数组int a[100],要对从a[0]到a[99]的元素进行排序,只要写sort(a,a+100)就行了,默认的排序方式是升序。 拿我出的“AC的策略”这题来说,需要对数组t的第... 阅读全文
posted @ 2013-01-13 15:54 huashiyiqike 阅读(579) 评论(0) 推荐(0) 编辑
摘要: 大数:求下一个质数#include "stdio.h"#include "math.h"#define maxsize 1000000int main(){ __int64 i,j,temp,count,sq,n; bool flag=true; scanf("%I64d",... 阅读全文
posted @ 2013-01-13 15:23 huashiyiqike 阅读(478) 评论(0) 推荐(0) 编辑
  2013年1月12日
摘要: 用整形数组保存数据,每一位最后在0~9范围之内。#include "cstdio"#include "cstring"#include "cstdlib"int res[10010];int main(){ int n; while (scanf("%d", &n) == 1) { int i, j; memset(res, 0, sizeof(res)); res[0] = 1; res[1] = 1; for (i = 2; i <= n; i++) { for (j... 阅读全文
posted @ 2013-01-12 19:27 huashiyiqike 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdio.h" 2 #include "stdlib.h" 3 #include "string.h" 4 #include "math.h" 5 typedef struct stu 6 { 7 char num[100];//尽量开大数组 8 char name[100]; 9 char sex[3];10 int age;11 }stu;12 int main()13 {14 int n,m,exist;15 int i,j;16 char temp[100];17 stu *a=( 阅读全文
posted @ 2013-01-12 13:16 huashiyiqike 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdio.h" 2 #include "stdlib.h" 3 #include "string.h" 4 #include <iostream> 5 using namespace std; 6 typedef struct student 7 { 8 int age,grade; 9 char a[100];10 }student;11 int main()12 {13 int n,i,visit[10000],min,record,j;14 student *s=(student*)mall 阅读全文
posted @ 2013-01-12 09:24 huashiyiqike 阅读(167) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7