Implementint sqrt(int x).Compute and return the square root ofx.二分法, 在[0, x/2 + 1]区间内折半查找。注意mid * mid 可能会溢出。int sqrt(int x) { unsigned long...
分类:
其他好文 时间:
2014-12-07 16:20:21
阅读次数:
163
这次整理的是函数指针和指针函数这是指针的调用:代码:#include #include using namespace std;typedef unsigned char unit8_t;extern void swapdata(unit8_t dat_x, unit8_t dat_y);int m...
分类:
其他好文 时间:
2014-12-07 06:30:56
阅读次数:
175
这次整理的是函数指针和指针函数
这是指针的调用:
代码:
#include
#include
using namespace std;
typedef unsigned char unit8_t;
extern void swapdata(unit8_t dat_x, unit8_t dat_y);
int main()
{
unit8_t x, y;
scanf("%d...
分类:
其他好文 时间:
2014-12-07 01:23:00
阅读次数:
131
一、原型:extern void *malloc(unsigned int num_bytes);头文件:#include 或 #include (注意:alloc.h 与 malloc.h 的内容是完全一致的。)功能:分配长度为num_bytes字节的内存块说明:如果分配成功则返回指向被分配内.....
分类:
其他好文 时间:
2014-12-06 11:16:18
阅读次数:
161
1、 在Windows系统中输入文件结束符的方法为Ctrl+Z
2、 如何选择类型?
1) Use an unsigned type when youknow that the values cannot be negative
2) Use int for integer arithmetic.short is usually too small a...
分类:
编程语言 时间:
2014-12-05 21:24:37
阅读次数:
313
下面这个位运算小技巧可以迅速给出一个数的二进制表达中末尾有多少个 0 。比如, 123 456 的二进制表达是 1 11100010 01000000 ,因此这个程序给出的结果就是 6 。以下是代码片段:unsigned int v; // find the number of trailing ....
分类:
其他好文 时间:
2014-12-05 21:10:14
阅读次数:
222
#include int main(int argc, char *argv[]){ int i; FILE *fp = NULL; unsigned char *pData; int iLen, itmpLen, itmp; fp = fopen(argv[1], "...
分类:
其他好文 时间:
2014-12-05 20:54:06
阅读次数:
237
用于对一个文件进行CRC校验,以确保文件数据传输的正确性。
废话不多说,直接上代码!
crc32.h
#ifndef CRC_32_H
#define CRC_32_H
#ifdef __cplusplus
extern "C" {
#endif
void init_crc_table(void);
unsigned int crc32(unsigned int crc,unsi...
分类:
其他好文 时间:
2014-12-05 12:49:55
阅读次数:
206
和机器字长及编译器有关系:所以,int,long int,short int的宽度都可能随编译器而异。但有几条铁定的原则(ANSI/ISO制订的):1 sizeof(short int)<=sizeof(int) 2 sizeof(int)<=sizeof(long int) 3 short int...
分类:
编程语言 时间:
2014-12-05 12:08:30
阅读次数:
234
//
// main.m
// struct
//
// Created by mac on 14-12-2.
// Copyright (c) 2014年
mac. All rights reserved.
//
#import
#pragma mark
基本数据类型----
void
baseType()
{
//unsigned l...
分类:
其他好文 时间:
2014-12-04 20:02:22
阅读次数:
167