3D FPS

1234567890

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  57 Posts :: 2 Stories :: 57 Comments :: 0 Trackbacks

常用链接

留言簿(10)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

#

//2010/10/22 21:17:07 FRI

//用c++程序编写:
//在九宫格里填写数字,纵、横、斜(对角)相加=15
//create by jims


#include < iostream>

// +----+----+----+
// |1   |2   | 3  |
// +----+----+----+
// |4   |5   |6   |
// +----+----+----+
// |7   |8   |9   |
// +----+----+----+
// ADS:use emacs table-insert

bool check(int* a,int num)
{

    //std::cout<<a[1]<<a[2]<<a[3]<<a[4]<<a[5]<<a[6]<<a[7]<<a[8]<<a[9]<<std::endl;
    if( (a[1]+ a[2] +a[3] ==15)
        && (a[4] + a[5] + a[6] == 15)
        && (a[7] + a[8] + a[9] == 15)
        && (a[1] + a[4] + a[7] == 15)
        && (a[2] + a[5] + a[8] == 15)
        && (a[3] + a[6] + a[9] == 15)
        && (a[1] + a[5] + a[9] == 15)
        && (a[3] + a[5] + a[7] == 15)
        )
    {
        for( int i = 1; i <= 9; i++)
        {
            for( int j = 1; j <= 9; j++)
            {
                if( i != j
                 &&  a[i] == a[j])
                    return false;
            }
        }
        return true;
    }
    else
        return false;
}

int main(int argc, char* argv[])
{
    int a[10];
    bool find = false;

    for( a[1] = 1; a[1] <= 9; a[1]++){
    for( a[2] = 1; a[2] <= 9; a[2]++){        
    for( a[3] = 1; a[3] <= 9; a[3]++){
    for( a[4] = 1; a[4] <= 9; a[4]++){        
    for( a[5] = 1; a[5] <= 9; a[5]++){
    for( a[6] = 1; a[6] <= 9; a[6]++){
    for( a[7] = 1; a[7] <= 9; a[7]++){        
    for( a[8] = 1; a[8] <= 9; a[8]++){
    for( a[9] = 1; a[9] <= 9; a[9]++){
        if( check( a,9))
        {
            find = true;
            std::cout<<a[1]<<a[2]<<a[3]<<a[4]<<a[5]<<a[6]<<a[7]<<a[8]<<a[9]<<std::endl;
            goto leble_find;
        }
    }}}}}}}}}

leble_find:    
    if( find)
    {
        std::cout<<a[1]<<" "<<a[2]<<" "<<a[3]<<"\n";
        std::cout<<a[4]<<" "<<a[5]<<" "<<a[6]<<"\n";
        std::cout<<a[7]<<" "<<a[8]<<" "<<a[9]<<"\n";
    }
    else
        std::cout<<"can't find\n";

    std::cin.get();
    
}


posted @ 2010-10-22 22:39 DK_jims 阅读(323) | 评论 (0)编辑 收藏


;;;C:\Documents and Settings\jims_mrs\Application Data

1
 (load-file "D:/Program Files/emacs/HOME/.emacs")
2 
3 ;;; Emacs Load Path
4 ;;(setq load-path (cons "D:/Program Files/emacs/HOME/.emacs" load-path))

D:\Program Files\emacs\HOME
  1 
  2 (setenv "HOME" "D:/Program Files/emacs/HOME")
  3 (setenv "PATH" "D:/Program Files/emacs/HOME")
  4 ;;set the default file path
  5 (setq default-directory "~/")
  6 (add-to-list 'load-path "~/emacs/site-lisp")
  7 
  8 
  9 ;;(server-start)
 10 
 11 
 12 
 13 
 14 ;; 动态加载的代码
 15 ;; M-x load-file,
 16 ;; M-x eval-buffer
 17 
 18 ;关闭启动画面
 19 (custom-set-variables
 20   ;; custom-set-variables was added by Custom.
 21   ;; If you edit it by hand, you could mess it up, so be careful.
 22   ;; Your init file should contain only one such instance.
 23   ;; If there is more than one, they won't work right.
 24  '(column-number-mode t)
 25  '(display-time-mode t)
 26  '(inhibit-startup-screen t)
 27  '(show-paren-mode t)
 28  '(truncate-partial-width-windows nil))
 29 
 30 ;;设置个人信息
 31 (setq user-full-name "mrx jimsmorong")
 32 (setq user-mail-address "jimsmorong@gmail.com"
 33 
 34 ;;加载颜色
 35 (require 'color-theme)
 36 ;;M-x color-theme-select
 37 ;;选择哪一种颜色
 38 (color-theme-comidia)
 39 
 40 ;;加载lua mode
 41 (require 'lua-mode)
 42 
 43 ;;加载google_protobuf
 44 (require 'protobuf-mode)
 45 
 46 ;;加载CSope
 47 (require 'xcscope) ;;加载xcscope
 48 
 49 ;;加载yasnippet
 50 ;;(require 'yasnippet/yasnippet) ;; not yasnippet-bundle
 51 ;;(yas/initialize)
 52 ;;(yas/load-directory "~/.emacs.d/plugins/yasnippet-0.6.1c/snippets")
 53 
 54 ;;load browse-kill-ring
 55 (require 'browse-kill-ring)
 56 (global-set-key [(control c)(k)] 'browse-kill-ring)
 57 (browse-kill-ring-default-keybindings)
 58 
 59 ;;配置ido插件,这个可以使你在用C-x C-f打开文件的时候在后面有提示
 60 ;;----------------------------------------------------------------------------------------
 61 (require 'ido)
 62 (ido-mode t)
 63 ;;---------------------------------------------------------------------------------------- 
 64 
 65 
 66 
 67 
 68 ;;加载tabbar.el
 69 ;;------------------------------------------------------------------------------------------------------------------------------------------
 70 (require 'tabbar)
 71 (tabbar-mode t)
 72 (global-set-key [(control shift tab)] 'tabbar-backward)
 73 (global-set-key [(control tab)]       'tabbar-forward)
 74 ;;默认的分组方法并不是每个人都喜欢,它会把后缀名相同的文件分为一组,
 75 ;;比如说perl脚本都扔在一个组里,yaml文件又扔在另一个组里。写代码的时候,
 76 ;;在这两个组里切换实在是太麻烦了!我就喜欢把除了Emacs Buffer之外的文件
 77 ;;都放成一组,即我自己打开的文件放成一组
 78 (setq tabbar-buffer-groups-function
 79     (lambda (b) (list "All Buffers")))
 80 (setq tabbar-buffer-list-function
 81     (lambda ()
 82         (remove-if
 83           (lambda(buffer)
 84              (find (aref (buffer-name buffer) 0" '"))
 85           (buffer-list))))
 86 
 87 ;;------------------------------------------------------------------------------------------------------------------------------------------
 88 
 89 ;;load line_number
 90 ;;(set-scroll-bar-mode nil)   ; no scroll bar, even in x-window system (recommended)
 91 ;;(require 'wb-line-number)
 92 ;;(wb-line-number-toggle)
 93 
 94 
 95 ;;显示时间
 96 (display-time)
 97 
 98 ;;显示行号
 99 (column-number-mode t)
100 (show-paren-mode t)
101 
102 ;;去掉工具栏
103 (tool-bar-mode nil)
104 
105 ;;去掉菜单栏
106 ;;ctrl+鼠标右键 可以按出菜单
107 ;;(menu-bar-mode nil)
108 
109 ;;去掉滚动条
110 (set-scroll-bar-mode nil)
111 
112 ;;关闭烦人的出错时的提示声
113 (setq visible-bell t)
114 
115 ;;滚动页面时比较舒服,不要整页的滚动
116 (setq     scroll-step 1
117 scroll-margin 3
118 scroll-conservatively 10000)
119 
120 ;在标题栏显示buffer的名字
121 (setq frame-title-format "%b@emacs")
122 
123 ;;设置默认工作目录
124 (setq default-directory "D:/Program Files/emacs/mrx")
125 ;;(setq default-directory "d:/mate2/dqprotocol")
126 
127 ; F5:激活speedbar
128 (global-set-key [(f5)] 'speedbar-get-focus)
129 
130 ;;动态增加减少字体大小
131 (defun sacha/increase-font-size ()
132   (interactive)
133   (set-face-attribute 'default
134                       nil
135                       :height
136                       (ceiling (* 1.10
137                                   (face-attribute 'default :height)))))
138 (defun sacha/decrease-font-size ()
139   (interactive)
140   (set-face-attribute 'default
141                       nil
142                       :height
143                       (floor (* 0.9
144                                   (face-attribute 'default :height)))))
145 (global-set-key (kbd "C-+"'sacha/increase-font-size)
146 (global-set-key (kbd "C--"'sacha/decrease-font-size)
147 
148 
149 
150 (custom-set-faces
151   ;; custom-set-faces was added by Custom.
152   ;; If you edit it by hand, you could mess it up, so be careful.
153   ;; Your init file should contain only one such instance.
154   ;; If there is more than one, they won't work right.
155  '(default ((t (:inherit nil :stipple nil :background "Black" :foreground "SteelBlue" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight bold :height 90 :width normal :foundry "outline" :family #("微软雅黑" 0 4 (charset chinese-gbk)))))))
156 
157 ;; read pdf
158 ;;(load-file "~/dos/emacs/doc-view.el")
159 ;;(require 'doc-view)
160 
161 
162 
163 
164 
165 
166 ;;
167 ;;(setq gnuwin32_bin "GetGnuWin32\gnuwin32\bin")
168 (setq gnuwin32_bin "D:/Program Files/GetGnuWin32/gnuwin32/bin;")
169 
170 (setenv "PATH"
171         (concat
172           gnuwin32_bin 
173           (getenv "PATH")
174          )
175         )
176 
177 
178 (require 'doc-view)
179 
180 ;;配置linum插件,显示行号
181 ;;-----------------------------------------------------------------------------------
182 (require 'linum)
183 (global-linum-mode t)
184 ;;----------------------------------------------------------------------------------- 
185 
186 
187   (defun my-insert-date ()
188     (interactive)
189     (insert "//")
190     (insert (user-full-name))
191     (insert "@")
192     (insert (format-time-string "%Y/%m/%d %H:%M:%S" (current-time))))
193   (global-set-key (kbd "C-c m d"'my-insert-date)
194 
195 
196 (require 'cmake-mode)


将附件保存在D:\Program Files\emacs\ntemacs23\site-lisp

http://www.cppblog.com/Files/jimsmorong/site-lisp.zip




posted @ 2010-05-10 21:46 DK_jims 阅读(476) | 评论 (1)编辑 收藏

visual studio 是一个十分优秀的IDE
我在网上找了一些背景色是黑色的
保护眼睛



下载文件
 http://www.cppblog.com/Files/jimsmorong/vs_black.rar

另存为 解压 6K 点那个reg 就OK

posted @ 2010-04-07 21:51 DK_jims 阅读(855) | 评论 (1)编辑 收藏

     摘要: 24点 算法 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->  1 #include "stdafx.h"  2 #include <iostream>&n...  阅读全文
posted @ 2010-04-05 14:16 DK_jims 阅读(224) | 评论 (0)编辑 收藏


http://code.google.com/p/darkingim/
玩玩开源

代码是自己写的一些东西 的集合

完成消息封装
network 层

boost.asio + protobuf

暂时未放上
posted @ 2009-12-20 22:14 DK_jims 阅读(85) | 评论 (0)编辑 收藏

看lua 好似无我以前想的那么简单

然后再看看luatinker一个封装库

再想想C

觉得lua里也有C++的思想 起码那个luaD luaK luaC 之类的前缀 给人感觉就像函数前的类名

还有好多想不明白 
posted @ 2009-04-30 06:30 DK_jims 阅读(91) | 评论 (0)编辑 收藏

转自http://www.cppblog.com/batiliu/archive/2008/11/26/67935.html






  非修改性序列操作(12个)

循环 对序列中的每个元素执行某操作 for_each()

查找 在序列中找出某个值的第一次出现的位置 find()

在序列中找出符合某谓词的第一个元素 find_if()

在序列中找出一子序列的最后一次出现的位置 find_end()

在序列中找出第一次出现指定值集中之值的位置 find_first_of()

在序列中找出相邻的一对值 adjacent_find()

计数 在序列中统计某个值出现的次数 count()

在序列中统计与某谓词匹配的次数 count_if()

比较 找出两个序列相异的第一个元素 mismatch()

两个序列中的对应元素都相同时为真 equal()

搜索 在序列中找出一子序列的第一次出现的位置 search()

在序列中找出一值的连续n次出现的位置 search_n()

  修改性序列操作(27个)

复制 从序列的第一个元素起进行复制 copy()

从序列的最后一个元素起进行复制 copy_backward()

交换 交换两个元素 swap()

交换指定范围的元素 swap_ranges()

交换由迭代器所指的两个元素 iter_swap()

变换 将某操作应用于指定范围的每个元素 transform()

替换 用一个给定值替换一些值 replace()

替换满足谓词的一些元素 replace_if()

复制序列时用一给定值替换元素 replace_copy()

复制序列时替换满足谓词的元素 replace_copy_if()

填充 用一给定值取代所有元素 fill()

用一给定值取代前n个元素 fill_n()

生成 用一操作的结果取代所有元素 generate()

用一操作的结果取代前n个元素 generate_n()

删除 删除具有给定值的元素 remove()

删除满足谓词的元素 remove_if()

复制序列时删除具有给定值的元素 remove_copy()

复制序列时删除满足谓词的元素 remove_copy_if()

唯一 删除相邻的重复元素 unique()

复制序列时删除相邻的重复元素 unique_copy()

反转 反转元素的次序 reverse()

复制序列时反转元素的次序 reverse_copy()

环移 循环移动元素 rotate()

复制序列时循环移动元素 rotate_copy()

随机 采用均匀分布来随机移动元素 random_shuffle()

划分 将满足某谓词的元素都放到前面 partition()

将满足某谓词的元素都放到前面并维持原顺序 stable_partition()

  序列排序及相关操作(27个)

排序 以很好的平均效率排序 sort()

排序,并维持相同元素的原有顺序 stable_sort()

将序列的前一部分排好序 partial_sort()

复制的同时将序列的前一部分排好序 partial_sort_copy()

n个元素 将第n各元素放到它的正确位置 nth_element()

二分检索 找到大于等于某值的第一次出现 lower_bound()

找到大于某值的第一次出现 upper_bound()

找到(在不破坏顺序的前提下)可插入给定值的最大范围 equal_range()

在有序序列中确定给定元素是否存在 binary_search()

归并 归并两个有序序列 merge()

归并两个接续的有序序列 inplace_merge()

有序结构上的集合操作 一序列为另一序列的子序列时为真 includes()

构造两个集合的有序并集 set_union()

构造两个集合的有序交集 set_intersection()

构造两个集合的有序差集 set_difference()

构造两个集合的有序对称差集(并-交) set_symmetric_difference()

堆操作 向堆中加入元素 push_heap()

从堆中弹出元素 pop_heap()

从序列构造堆 make_heap()

给堆排序 sort_heap()

最大和最小 两个值中较小的 min()

两个值中较大的 max()

序列中的最小元素 min_element()

序列中的最大元素 max_element()

词典比较 两个序列按字典序的第一个在前 lexicographical_compare()

排列生成器 按字典序的下一个排列 next_permutation()

按字典序的前一个排列 prev_permutation()


posted @ 2009-02-23 21:27 DK_jims 阅读(309) | 评论 (0)编辑 收藏

C++ 枚举类型的思考(转载)

原文网址:  http://blog.csdn.net/classfactory/archive/2004/08/29/87749.aspx

C++ 中的枚举类型继承于 C 语言。就像其他从 C 语言继承过来的很多特性一样,C++ 枚举也有缺点,这其中最显著的莫过于作用域问题——在枚举类型中定义的常量,属于定义枚举的作用域,而不属于这个枚举类型。例如下面的示例:

enum FileAccess {
    Read = 0x1,
    Write = 0x2,
};

FileAccess access = ::Read; // 正确
FileAccess access = FileAccess::Read; // 错误

C++枚举的这个特点对于习惯面向对象和作用域概念的人来说是不可接受的。首先,FileAccess::Read 显然更加符合程序员的直觉,因为上面的枚举定义理应等价于如下的定义(实际上,.NET 中的枚举类型便是如此实现的):

class FileAccess {
    static const int Read = 0x1;
    static const int Write = 0x2;
};

其次,这导致我们无法在同一个作用域中定义两个同样名称的枚举值。也就是说,以下的代码是编译错误:

enum FileAccess {
    Read = 0x1,
    Write = 0x2,
};

enum FileShare {
    Read = 0x1, // 重定义
    Write = 0x2, // 重定义
};

如果这一点没有让你恼怒过的话,你可能还没写过多少 C++ 代码 :-)。实际上,在最新的 C++0x 标准草案中有关于枚举作用域问题的提案,但最终的解决方案会是怎样的就无法未卜先知了,毕竟对于象 C++ 这样使用广泛的语言来说,任何特性的增删和修改都必须十分小心谨慎。

当然,我们可以使用一些迂回的方法来解决这个问题(C++ 总是能给我们很多惊喜和意外)。例如,我们可以把枚举值放在一个结构里,并使用运算符重载来逼近枚举的特性:

struct FileAccess {
    enum __Enum {
        Read = 0x1,
        Write = 0x2
    };
    __Enum _value; // 枚举值

    FileAccess(int value = 0) : _value((__Enum)value) {}
    FileAccess& operator=(int value) {
        this->_value = (__Enum)value;
        return *this;
    }
    operator int() const {
        return this->_value;
    }
};

我们现在可以按照希望的方式使用这个枚举类型:

FileAccess access = FileAccess::Read;

并且,因为我们提供了到 int 类型的转换运算符,因此在需要 int 的地方都可以使用它,例如 switch 语句:

switch (access) {
    case FileAccess::Read:
        break;
    case FileAccess::Write:
        break;
}

当然我们不愿意每次都手工编写这样的结构。通过使用宏,我们可以很容易做到这一点:

#define DECLARE_ENUM(E) \
struct E \
{ \
public: \
    E(int value = 0) : _value((__Enum)value) { \
    } \
    E& operator=(int value) { \
        this->_value = (__Enum)value; \
        return *this; \
    } \
    operator int() const { \
        return this->_value; \
    } \
\
    enum __Enum {

#define END_ENUM() \
    }; \
\
private: \
    __Enum _value; \
};

我们现在可以按如下的方式定义前面的枚举,并且不比直接写 enum 复杂多少。

DECLARE_ENUM(FileAccess)
    Read = 0x1,
    Write = 0x2,
END_ENUM()

DECLARE_ENUM(FileShare)
    Read = 0x1,
    Write = 0x2,
END_ENUM()
posted @ 2009-02-19 22:40 DK_jims 阅读(309) | 评论 (0)编辑 收藏

放些代码上来 懒得打字:
因为这个东西 有些很不爽

#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
//#include "DKcommit.hpp"
template<class T>
struct printT
{    // functor for operator>
    void operator()(const T& _t) const
    {   
        printf("%d ",_t);
        //return true;
    }
};
#define UseThisFile
#ifdef UseThisFile

#define iPageItemCount 15

int PageConcontArray[iPageItemCount];

void GiveSpecDateAtPage(std::vector<int> &vecAllDate, int ipage,int *pIntArray)
{
    std::vector<int>::iterator it;
     if (vecAllDate.size() == 0)
     {
           return ;
     }
    if (vecAllDate.size() > (ipage + 1) * iPageItemCount )
     {
          for (it = vecAllDate.begin() + ipage * iPageItemCount ; it != vecAllDate.begin() + (ipage + 1) * iPageItemCount ;it++)
          {
                 *pIntArray = *it;
                 pIntArray ++;
          }
     }
     else if (vecAllDate.size() < (ipage +1 ) * iPageItemCount
                 && vecAllDate.size() > (ipage) * iPageItemCount )
     {
         for (it = vecAllDate.begin() + ipage * iPageItemCount ; it != vecAllDate.end() ;it++)
         {
             *pIntArray = *it;
             pIntArray ++;
         }
     }
}
//iPageItemCount



void GivedDescDateAtPage(std::vector<int> &vecAllDate, int ipage,int *pIntArray)
{
    std::vector<int>::iterator it;
   

    //int iPageCount = vecAllDate.size() / iPageItemCount;
   
    if (vecAllDate.size() == 0)
    {
        return ;
    }
    if (vecAllDate.size() > (ipage + 1) * iPageItemCount )
    {
        for (it = vecAllDate.end() -1 - (ipage ) * iPageItemCount ; it != vecAllDate.end() - 1  - (ipage +1 ) * iPageItemCount ;it--)
        {
            *pIntArray = *it;
            pIntArray ++;
        }
    }
    else if (vecAllDate.size() <= (ipage +1 ) * iPageItemCount
        && vecAllDate.size() > (ipage) * iPageItemCount )
    {
        //int icount;
        //for (icount = vecAllDate[vecAllDate.size() - vecAllDate.size() % iPageItemCount  - ipage * iPageItemCount] ; icount >= 0  ;icount--)
        //%for (it = vecAllDate.begin(); it != vecAllDate.end() /* - 1*/- ipage * iPageItemCount  ;it++)
        for ( it = vecAllDate.end()  - 1- ipage * iPageItemCount  ;it != vecAllDate.begin()  ;it--)
        {
            //*pIntArray = *(&vecAllDate[icount]);
            *pIntArray = *it;
            pIntArray ++;
        }
        *pIntArray =  *(&vecAllDate[0]);
    }
}


void main()
{
    printf("helloWorld\n");

    std::vector<int> a;
    for (int i = 1; i < 11; i ++)
    {
        a.push_back(i);
    }

    std::for_each(a.begin(),a.end(),printT<int>() );

    printf("\n");

    std::for_each(PageConcontArray,PageConcontArray+10,printT<int>());
    printf("\n");
   

    for (int iPage = 0 ;iPage <= 19;iPage ++)
    {
        printf("This is %d page  :",iPage);
        int a1 = ARRAY_SIZE(PageConcontArray);
        int b2 = sizeof(PageConcontArray)/sizeof(PageConcontArray[0]);
  
        for (int i = 0; i < iPageItemCount ;i++)
        {
            PageConcontArray[i] = 0;
        }
   
       //std::for_each(PageConcontArray,PageConcontArray+iPageItemCount,printT<int>());
       GiveSpecDateAtPage(a,iPage,PageConcontArray);
       std::for_each(PageConcontArray,PageConcontArray+iPageItemCount,printT<int>());
       printf("\n");
    }


    for (int iPage = 0 ;iPage <= 19;iPage ++)
    {
        printf("This is %d page  :",iPage);
        int a1 = ARRAY_SIZE(PageConcontArray);
        int b2 = sizeof(PageConcontArray)/sizeof(PageConcontArray[0]);

        for (int i = 0; i < iPageItemCount ;i++)
        {
            //printf("FFF< %d > sdf",i);
            PageConcontArray[i] = 0;
        }


        //std::for_each(PageConcontArray,PageConcontArray+iPageItemCount,printT<int>());
        GivedDescDateAtPage(a,iPage,PageConcontArray);
        std::for_each(PageConcontArray,PageConcontArray+iPageItemCount,printT<int>());
        printf("\n");
    }




    //std::for_each(PageConcontArray,PageConcontArray+10,printT<int>());

    printf("\n");
    //printf("\n");


   

    getchar();
}


#endif




posted @ 2009-02-08 03:17 DK_jims 阅读(216) | 评论 (2)编辑 收藏

C++ 文本读写


C++文本读写保存 如果是中文 用wofstream 宽字保存 中文字

竟然不可以

原来 是要用一个local 本地环境才可以的

代码如下:

#include "stdafx.h"
#include <fstream>
//#include <>
int _tmain(int argc, _TCHAR* argv[])
{
    std::locale::global(std::locale(""));

    wchar_t a[140]= L"中中";
    std::wifstream f;
    f.open(L"1.txt");
    //f.write(a,10);
    f.read(a,140);

   
    f.close();
    //getchar();
    return 0;
}
posted @ 2009-01-31 19:46 DK_jims 阅读(368) | 评论 (1)编辑 收藏

仅列出标题
共6页: 1 2 3 4 5 6