自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(34)
  • 收藏
  • 关注

原创 单链表逆置

今天去昆仑在线笔试,其中一题是写一个单链表逆置函数,节点如下: struct Node {     int Value;     Node *next; }; 之前还真没有写过,只好想了个笨办法了。结构体比较简单,那只交换value的值好了。 Node *getByNum(int n,Node* head) {     int i=0;     while(n--)     {         if(head->next != NULL)             head = head->next;    

2011-03-28 18:13:00 231

转载 堆和栈的区别(转过无数次的文章)

一、预备知识—程序的内存分配     一个由C/C++编译的程序占用的内存分为以下几个部分     1、栈区(stack)—   由编译器自动分配释放   ,存放函数的参数值,局部变量的值等。其     操作方式类似于数据结构中的栈。     2、堆区(heap)   —   一般由程序员分配释放,   若程序员不释放,程序结束时可能由OS回     收   。注意它与数据结构中的堆是两回事,分配方式倒是类似于链表,呵呵。     3、全局区(静态区)(static)—,全局变量和静态变量的存储是放在一块的

2011-03-24 10:25:00 185

转载 字节对齐详解

一.什么是字节对齐,为什么要对齐?    现代计算机中内存空间都是按照byte划分的,从理论上讲似乎对任何类型的变量的访问可以从任何地址开始,但实际情况是在访问特定类型变量的时候经常在特 定的内存地址访问,这就需要各种类型数据按照一定的规则在空间上排列,而不是顺序的一个接一个的排放,这就是对齐。    对齐的作用和原因:各个硬件平台对存储空间的处理上有很大的不同。一些平台对某些特定类型的数据只能从某些特定地址开始存取。比如有些架构的CPU在访问 一个没有进行对齐的变量的时候会发生错误,那么在这种架构下编程必

2011-03-17 17:48:00 186

原创 “Short a:4”——指定位数的成员变量

    结构体或类中有时会见到下面的写法struct s{         short a:4;         short b:6;         short c:8;};    这是结构体和类的一种性质,在声明变量的同时指明变量的位数。    short类型在32位机上本来是16位的,但从节约空间等角度的考虑,我们觉得用16位来存储有些浪费,有个4位的变量就够用了,怎么办?    当然有办法,我们在声明变量的同时,在变量后面加上冒号,再加上数字,表示这个变量只占用这么多位。注意数字不能大于原类型的位数

2011-03-17 02:18:00 280

原创 ++的实验

#include int main(){ int a = 4; printf("a=4/n"); printf("(a)*(++a)=%d/ta=%d/n",(a)*(++a),a); a = 4; printf("(++a)*(++a)=%d/ta=%d/n",(++a)*(++a),a); a = 4; printf("(a++)*(a++)=%d/ta=%d/n",(a++)*(a++),a); a = 4; printf("(a++)*(a)=%d/ta=

2011-02-11 14:34:00 183

原创 C++内联函数(Inline)

inline 关键字用来定义一个类的内联函数,引入它的主要原因是用它替代C中表达式形式的宏定义。表达式形式的宏定义一例:#define ExpressionName(Var1,Var2) ((Var1)+(Var2))*((Var1)-(Var2))1.为什么会使用表达式形式的宏1).宏的执行效率高。因为它是在代码中需要的位置直接文本替换,没有参数压栈,代码生成等操作,是由预处理器完成的。2).函数的调用需要保存和恢复现场,有一定的时间和空间的开销。2.表达式形式的宏的缺点1).宏不能访问对象的私有和保护成

2011-02-11 14:05:00 377

原创 VS2008+qt4.6.2+Visual Studio Add-in环境配置

<br />早就不爽qt的IDE了,这下终于解脱了<br /> <br />1. 下载用于 Windows 的Qt 库 4.6.2 (VS 2008, 194 Mb)<br />   http://qt.nokia.com/downloads/windows-cpp-vs2008<br />2.下载visual studio Add-in<br />   http://qt.nokia.com/downloads/visual-studio-add-in<br />3.配置系统环境变量<br />   增加

2010-06-07 21:08:00 676

原创 使用“VS2008”编译Platform SDK中Filters的例子

编译Platform SDK包中的一个directshow的Filters的例子(ezrgb24),不使用makefile编译,使用vs2008的集成开发环境编译的步骤注:PSDK = Platform SDK 安装目录一、先用 (PSDK)/Samples/Multimedia/DirectShow/BaseClasses下的Makefile文件编译出strmbasd.lib(这是D

2010-03-11 03:16:00 953

原创 编译Platform SDK包中的一个directshow的Filters的例子

编译Platform SDK包中的一个directshow的Filters的例子,使之生成ax文件并能成功注册正常使用 需求:1.安装VS2.安装Microsoft DirectX SDK 9.0 (2005/2)或更高版本(编译Platform中的DirectShow例子所必须)3.安装Microsoft Platform SDK for Windows Server 2003 R2

2010-03-05 11:36:00 541

转载 运行VS提示"找不到一个或多个组件,请重新安装该应用程序"错误的解决方法VS

转自:http://www.cnblogs.com/dreamof/archive/2009/04/15/1436627.html  运行Visual Studio 2003或Visual Studio 2008提示"找不到一个或多个组件,请重新安装该应用程序"错误的解决方法:1、在运行中输入regedit打开系统注册表;2、在注册表中查找项目:HKEY_CLASSES_R

2010-01-12 20:27:00 3049

转载 Windows2003环境下安装VS2008,.NetFramework3.5组件安装失败的解决

转自:http://www.cnblogs.com/chunshen/archive/2009/08/13/1545127.html由于经历过不少挫折,所以安装之前,找了不少资料先参考一下。之前安装VS2008时,发现与Office2007冲突,在搜索了网络以后并请教一些朋友,发现其顺序是先VS2008然后Office2007,并且最好在vs2008之前安装SQL2005。可是,在

2010-01-12 20:16:00 1199

原创 博弈(入门)个人心得

博弈(入门)个人心得马尚  2009年3月5日关键词:必败态,异或 我们先看下这张图┏→ 一定 →┓必败态      胜态┗← 可能 ←┛以下象棋为例,说明上面图示所表示的含义。假如你和一个人在对弈并处于这样一种局面:你已经将了对方的军,轮到对手走棋,对手无论如何都无法补救。这种局面就是必败态, 对应上面的图来看,就是对于对手来说的“必败态”,无论他怎样走都“必定”

2009-03-05 23:20:00 425

原创 hdu_1312_Red and Black

hdu_1312_Red and Black Problem 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

2008-11-24 22:49:00 413

原创 pku_1008_玛雅历

pku_1008_玛雅历 Description上周末,M.A. Ya教授对古老的玛雅有了一个重大发现。从一个古老的节绳(玛雅人用于记事的工具)中,教授发现玛雅人使用了一个一年有365天的叫做Haab的历法。这个Haab历法拥有19个月,在开始的18个月,一个月有20天,月份的名字分别是pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen,

2008-11-13 20:26:00 1133

原创 pku_3062_Celebrity jeopardy

pku_3062_Celebrity jeopardy DescriptionIts hard to construct a problem thats so easy that everyone will get it, yet still difficult enough to be worthy of some respect. Usually, we err on one

2008-11-13 13:48:00 285

原创 pku_2578_Keep on Truckin'

pku_2578_Keep on Truckin DescriptionBoudreaux and Thibodeaux are on the road again . . . "Boudreaux, we have to get this shipment of mudbugs to Baton Rouge by tonight!" "Dont worry, Thibod

2008-11-13 13:44:00 311

原创 pku_2105_IP Address

pku_2105_IP Address DescriptionSuppose you are reading byte streams from any device, representing IP addresses. Your task is to convert a 32 characters long sequence of 1s and 0s (bits) to a

2008-11-13 13:41:00 232

原创 pku_2039_To and Fro

pku_2039_To and Fro DescriptionMo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns,

2008-11-13 13:31:00 420

原创 pku_2027_No Brainer

pku_2027_No Brainer DescriptionZombies love to eat brains. Yum. InputThe first line contains a single integer n indicating the number of data sets. The following n lines each represent a

2008-11-13 13:29:00 503

原创 pku_2017_Speed Limit

pku_2017_Speed Limit DescriptionBill and Ted are taking a road trip. But the odometer in their car is broken, so they dont know how many miles they have driven. Fortunately, Bill has a working

2008-11-13 13:25:00 345

原创 pku_1565_Skew Binary

pku_1565_Skew Binary DescriptionWhen a number is expressed in decimal, the kth digit represents a multiple of 10k. (Digits are numbered from right to left, where the least significant digit is n

2008-11-13 13:20:00 243

原创 pku_1658_Eva's Problem

pku_1658_Evas Problem DescriptionEva的家庭作业里有很多数列填空练习。填空练习的要求是:已知数列的前四项,填出第五项。因为已经知道这些数列只可能是等差或等比数列,她决定写一个程序来完成这些练习。 Input第一行是数列的数目t(0  Output对输入的每个数列,输出它的前五项。 Sample Input21

2008-11-12 23:08:00 241

原创 pku_2000_Gold Coins

pku_2000_Gold Coins DescriptionThe king pays his loyal knight in gold coins. On the first day of his service, the knight receives one gold coin. On each of the next two days (the second and thir

2008-11-12 21:15:00 725

原创 pku_1519_Digital Roots

pku_1519_Digital Roots DescriptionThe digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital ro

2008-11-12 19:51:00 264

原创 pku_1298_The Hardest Problem Ever

pku_1298_The Hardest Problem Ever DescriptionJulius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive,

2008-11-12 19:05:00 352

原创 pku_1250_Tanning Salon

pku_1250_Tanning Salon DescriptionTan Your Hide, Inc., owns several coin-operated tanning salons. Research has shown that if a customer arrives and there are no beds available, the customer will

2008-11-12 12:21:00 218

原创 pku_2136_Vertical Histogram

pku_2136_Vertical Histogram DescriptionWrite a program to read four lines of upper case (i.e., all CAPITAL LETTERS) text input (no more than 72 characters per line) from the input file and print

2008-11-11 14:35:00 272

原创 北大OJ的结构体

北大的OJ对于结构体的支持好像不完美,用结构体定义变量时只能用这种方式struct Q{    char string[51];    int num;}list[101],p;   //定义在此处 而不能用这种struct Q{    char string[51];    int num;};int main(){    

2008-11-10 16:55:00 251

原创 pku_1007_DNA Sorting

pku_1007_DNA Sorting DescriptionOne measure of ``unsortedness in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequ

2008-11-10 16:28:00 353

原创 pku_1006_生理周期

pku_1006_生理周期 Description人生来就有三个生理周期,分别为体力、感情和智力周期,它们的周期长度为23天、28天和33天。每一个周期中有一天是高峰。在高峰这天,人会在相应的方面表现出色。例如,智力周期的高峰,人会思维敏捷,精力容易高度集中。因为三个周期的周长不同,所以通常三个周期的高峰不会落在同一天。对于每个人,我们想知道何时三个高峰落在同一天。对于每个周期,我们会

2008-11-09 22:57:00 465 1

原创 pku_1005_I Think I Need a Houseboat

pku_1005_I Think I Need a Houseboat DescriptionFred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the land, he learned that the s

2008-11-09 22:47:00 311

原创 pku_1004_Financial Management

pku_1004_Financial Management DescriptionLarry graduated this year and finally has a job. Hes making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to g

2008-11-09 22:23:00 151

原创 pku_1003_Hangover

pku_1003_Hangover DescriptionHow far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (Were assuming that the c

2008-11-09 21:39:00 269

原创 pku_1000_A+B Problem

pku_1000_A+B Problem DescriptionCalculate a + b InputTwo integer a,,b (0 ≤ a,b ≤ 10) OutputOutput a + b Sample Input1 2 Sample Output3#include int main(){   int a

2008-11-09 20:58:00 201

空空如也

空空如也

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

TA关注的人

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