4.原创小代码
thinkinnight
这个作者很懒,什么都没留下…
展开
-
练习小程序1
在CU看到的帖子,写了一个程序。使用C语言写出以下函数,给你三个变量a,b,c,请不使用其他变量的情况下交换他们的值,使得a=b, b=c, c=a;原帖地址: http://bbs.chinaunix.net/viewthread.php?tid=883665&extra=page%3D1%26filter%3Ddigest此程序有问题,待修改#include stdio.h>void原创 2007-01-16 18:37:00 · 687 阅读 · 0 评论 -
short的字节数
一直以为short的大小和int是一样的,结果看《programming windows》的时候发现上面写的不一样,写了一个程序测试了一下,果然。记忆中,short 的字节大小是和int的最小值相等,而long是和int的最大值相等。测试环境:VS.NET 2003, WinXP, IA32测试代码:test.cpp#include iostream>using namespace std原创 2007-01-18 16:14:00 · 4566 阅读 · 0 评论 -
WNDCLASS
WNDCLASS wndclass; wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; w原创 2007-01-18 22:39:00 · 883 阅读 · 0 评论 -
STL Qsort使用
#include iostream>#include algorithm>#include vector>#include functional>using namespace std;template typename T> bool cmp(const T& num1, const T& num2)...{ return num1num2; }int main()...{原创 2007-01-19 17:57:00 · 1247 阅读 · 0 评论 -
通过类指针得到private成员的值
这个比较简单,了解了类的内存排布就可以写出来了,顺便试验一下代码插入功能。鄙视一下,竟然没有C和C++的单独列出,就只能用C#的了,反正差不多。#include cstdio>using namespace std;class a...{public: setb(int val) ...{ b = val; }private: int b;}原创 2007-01-16 18:31:00 · 704 阅读 · 0 评论 -
练习小程序2
使用C语言写出以下函数,给你一个用字符串表示的整数,请写一个函数把该字符串转化成为整数,并要求处理异常情况。函数体中的语句不能超过5句。同“练习小程序1”,原帖地址:http://bbs.chinaunix.net/viewthread.php?tid=883665&extra=page%3D1%26filter%3Ddigest题目不难,关键是 “函数体中的语句不能超过5句”远远超过5句的我的代原创 2007-01-16 18:41:00 · 608 阅读 · 0 评论