比方在插入有序链表的过程中。普通情况下要使用俩指针来遍历,而后还要推断是否在第一个位置插入;利用指针的指针后不须要另外考虑这样的特殊情况。代码:#include #include struct node{ int data; struct node *next;} *head;//sor...
分类:
其他好文 时间:
2015-07-02 20:55:34
阅读次数:
125
循环定义:某些代码会被重复执行分类: for1.格式:for(1;2;3) 语句A;2.执行的流程实例:1+2+3+4+5+.....+100#include int main(void){ int i; int sum=0; 1 2 3 for (i=1;iint mai...
分类:
其他好文 时间:
2015-07-02 20:53:58
阅读次数:
118
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1100首先按x坐标排序,然后相邻的三个点A,B,C 组成的三条直线必然有K(AC) 2 #include 3 #include 4 #include 5 #includ...
分类:
其他好文 时间:
2015-07-02 20:53:48
阅读次数:
137
#include Typedefsexception_ptr一种类型,描述了一个指向异常的指针terminate_handler一种类型,描述了一个适合作为terminate_handler的函数的指针unexperted_handler一种类型,描述了一个适合作为unexpected_handle...
分类:
其他好文 时间:
2015-07-02 20:53:34
阅读次数:
250
偷懒用set 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define rep(i,l,r) for(int i=l;is;11 const int inf=0x7fffffff;12 ll ans;13 int n,pre,o...
分类:
其他好文 时间:
2015-07-02 20:53:30
阅读次数:
159
#include
#include
int strstrcount( char *str1, char *str2 )
{
char *str = str1;
int c = 0;
while( (str = strstr( str, str2 )) != NULL )
{
c++;
str++;
}
return c...
分类:
其他好文 时间:
2015-07-02 19:35:39
阅读次数:
133
记录锁的功能是:当一个进程正在读或修改文件的某个部分时,它可以阻止其它进程修改同一文件区。fcntl函数可以实现这一功能。#include int fcntl(int fd, int cmd, ... /* arg */ );对于记录锁,cmd是F_GETLK、F_SETLK或F_SETLKW,第三个参数是一个指向flock结构的指针:struct flock {...
分类:
其他好文 时间:
2015-07-02 19:34:57
阅读次数:
112
标准c++中String类非常强大,合理使用,能极大提高编程效率,下面就对string类的用法进行总结。
头文件
#include
String类的构造函数如下:
1) string s; //生成一个空字符串s
2) string s(str) //拷贝构造函数生成str的复制品
3) string s(str,index) //将字符串str内“始于位置index...
分类:
编程语言 时间:
2015-07-02 19:34:39
阅读次数:
218
//字符串逆序输出
#include
#include
int main()
{
char str[50];
char temp;
int i,length=0;
gets(str);
length = strlen(str);
for(i = 0,length--;i
{
temp = str[i];
str[i] = str[length];
str[length...
分类:
其他好文 时间:
2015-07-02 19:34:21
阅读次数:
96
#include"stdio.h"
#include"malloc.h"
#include"stdlib.h"
typedef struct lNode
{
char data;
struct lNode *lchild;
struct lNode *rchild;
}LNODE,*Tree;
typedef struct Node
{
Tree data;
struct Node * Next;
}NODE, * PNODE;
typedef struct Stack
{
...
分类:
其他好文 时间:
2015-07-02 19:30:39
阅读次数:
135