C语言
urgemule
hash(x) == x
展开
-
立此存照(6)[C语言]rand()函数与srand函数
#include#include#includeint getR(){ srand((unsigned int)time(NULL)); return (int)rand()%3-1;}int main(){ int i=0; puts("BEGIN"); for(;i < 20;i++) printf("%d ", getR()); puts("\nEND");原创 2014-08-27 18:13:25 · 642 阅读 · 0 评论 -
立此存照(7)[C语言]continue与for的变量增值
#includeint main(){ int i=0, outer=0, inner=0; for(i=0;i < 10;outer++){ i++; if(i % 2 == 0) continue; inner++; } printf("i=%d\n", i); printf("inner=%d\n", inner); printf("outer=%d\n",原创 2014-08-27 21:09:59 · 630 阅读 · 1 评论 -
待补遗(4)[C]如何让编译器调用自定义函数而非同名库函数
#define toupper(ch) xtoupper(ch)int xtoupper(char ch){ puts("I'm function xtoupper."); if('a' <= ch && ch <= 'z') ch -= 'a' - 'A'; return ch;}原创 2014-10-25 17:45:58 · 1207 阅读 · 0 评论 -
立此存照(9)[C++]如何输出wchar_t类型的字符串和字符
#include #include //c->ctype,cmath;locale->local environmentusing std::cout;using std::endl;using std::wcout;int main(){ setlocale(LC_ALL, "chs");//输出wchar_t类型的必要条件 wchar_t s[] = L"中华上下五千年";原创 2014-10-18 13:34:44 · 4424 阅读 · 2 评论