函数的编码风格1.注释2,空行3,缩进4,参数长度,代码长度,语句长度要合适。5,少用全局变量6,指针仅作输入参数时,可用const
设置其为只读属性,避免其在函数中被修改。7,函数默认的输入输出参数为int
类型,无输入参数或输出参数时要注意用void8,入口参数进行断言检验来自为知笔记(Wiz)
分类:
其他好文 时间:
2014-05-04 11:10:26
阅读次数:
300
题目来源:CF 427D Match & Catch
题意:给出2个字符串 求最短的连续的公共字符串 并且该字符串在原串中只出现一次
思路:把2个字符串合并起来求height 后缀数组height的应用
#include
#include
#include
using namespace std;
const int maxn = 100010;
char s[maxn];
int s...
分类:
其他好文 时间:
2014-05-04 09:32:45
阅读次数:
315
博客:存储系统研究
微博:http://weibo.com/u/2203007022
(1) C语言可变参数
我们可以从C语言的printf得出可变参数的作用,printf函数的原型如下:
int printf ( const char * format, ... );
通过使用可变个数参数,就是传入的参数个数是可变的,如printf需要根...
分类:
编程语言 时间:
2014-05-04 00:24:27
阅读次数:
442
typename与class都可以用作模板形参定义的关键字,两者无异~~
可是,typename的用途并非仅限于此,如下面的代码:
{CSDN:CODE:323655}
在上述代码中,iter的类型是C::const_iterator,实际的类型取决于C的类型。const_iterator 同时也是C内部的typedef 类型名。 但是,在此处,编译器的行为不会是你预期的...
分类:
编程语言 时间:
2014-05-04 00:19:35
阅读次数:
330
(string.h)这个文件夹主要是定义了几个对字符串和数组进行操作的函数。功能很强大。下面是重要函数:strcpy、strncpystrcpy,strncpy这两个函数是对字符串的复制,很常用。memcpy函数原型:void
* memcpy ( void * destination, const...
分类:
其他好文 时间:
2014-05-03 23:10:14
阅读次数:
310
#pragma once#include namespace stds { class tool
{ public: std::string ws2s(const std::wstring& ws) { std::string curLocale =
setlocale(LC_ALL...
分类:
其他好文 时间:
2014-05-03 22:25:17
阅读次数:
318
在派生类中序列化一个基类
假如有一个基类如下:
class student_info
{
public:
student_info() {}
virtual ~student_info() {}
student_info(const std::string& sn, const std::string& snm, const std::string& sg)
: name_(sn),...
分类:
其他好文 时间:
2014-05-03 21:41:12
阅读次数:
356
第1部分 重新认识C语言C语言中常用的文件操作函数总结及使用方法演示代码 1. C语言中常用的文件操作函数总结(1) fopen作用:打开文件。表头文件:#include 定义函数:FILE *fopen(const char *path, const char *mode);函数说明:参数path字符串包含欲打开的文件路径及文件名,参数mode字符串则代表着流形态。mode有下列几种形态字符串:...
分类:
其他好文 时间:
2014-05-03 21:38:17
阅读次数:
279
Let's consider a triangle of numbers in which a number appears in the first line, two numbers appear in the second line, three in the third line, etc. Develop a program which will compute the largest ...
分类:
其他好文 时间:
2014-05-03 17:32:22
阅读次数:
284
题目:193 - Graph Coloring
题目大意:给出一个图,图里面有点和边,要求相邻的点不可以都是黑色的,问怎样上色黑色的点最多的,给出字典序最大的那种组合情况。#include
#include
const int N = 105;
int n, m, s[N][N], ans[N], cas, count, vis[N];
bool judge (int x, in...
分类:
其他好文 时间:
2014-05-03 17:22:31
阅读次数:
282