2011年12月17日

C语言猜字魔术

摘要: #include<iostream> #include<stdlib.h> using namespace std;int main(){ while(1) { unsigned char ch[3]="",c; int j,sum = 0,t; //j为换行标志 ,t为产生的新汉字的操作数 cout << endl << " *************************************************************** " << endl << &q 阅读全文

posted @ 2011-12-17 16:14 悲笑菩提 阅读(309) 评论(0) 推荐(0)

2011年12月14日

一天一算法系列之位运算进制转换

摘要: #include<iostream>using namespace std;int main(){ char k = 4; unsigned char a = 0x80; char b = 0x80; //注意a、b的区别 for(int i=0;i<8;i++) { if(k & a) cout << 1; else cout << 0; a>>=1; } cout << endl; for(int i=0;i<8;i++) { if(k & b) cout << 1; else cout & 阅读全文

posted @ 2011-12-14 19:50 悲笑菩提 阅读(98) 评论(0) 推荐(0)

C语言趣事之内存泄露

摘要: C语言定义变量,分配内存时采用的是栈模式,于是乎,就有了如此如此,这般这般的效果#include<iostream>using namespace std;int main(){ int a = 66666; int b = 22222; int c[2] = {333333,44444}; cout << " 修改前的值 " << endl; cout << " c[2]= " << c[2] << endl; cout << " c[3]= " & 阅读全文

posted @ 2011-12-14 19:15 悲笑菩提 阅读(495) 评论(0) 推荐(0)

一天一算法系列之筛法求素数

摘要: #include<iostream>using namespace std;int main(){ bool s[10000]; for(int i=0;i<10000;i++) s[i] = true; s[0] = s[1] = false; //排除0、1 for(int i = 2;i<100;i++) { if(s[i]){ for(int j=i*i;j<10000;j+=i) { s[j] = false; } } } for(int i=0,a=0;i<10000;i++) { if(s[i]) { cout << i <& 阅读全文

posted @ 2011-12-14 16:47 悲笑菩提 阅读(104) 评论(0) 推荐(0)

2011年12月13日

C\C++笔记之小技巧

摘要: 以下是一个关于switch和define的用法#include <windows.h>#include <windowsx.h>#include "main.h"#include "dialogs.h"#include "resource.h"#ifndef _D_D_HAN#define _D_D_HAN#define HANDLE_MSG(hwnd,message,fn) case (message): return HANDLE_##message((hwnd),(wParam),(lParam),(fn 阅读全文

posted @ 2011-12-13 22:37 悲笑菩提 阅读(137) 评论(0) 推荐(0)

导航