Mar 16

vim - 批量注释快捷键 不指定

felix021 @ 2009-3-16 11:41 [IT » 软件] 评论(1) , 引用(0) , 阅读(8472) | Via 本站原创
其实得自己做个map

$ vim ~/.vimrc
"F5 for comment
vmap <F5> :s=^\(//\)*=//=g<cr>:noh<cr>
nmap <F5> :s=^\(//\)*=//=g<cr>:noh<cr>
imap <F5> <ESC>:s=^\(//\)*=//=g<cr>:noh<cr>
"F6 for uncomment
vmap <F6> :s=^\(//\)*==g<cr>:noh<cr>
nmap <F6> :s=^\(//\)*==g<cr>:noh<cr>
imap <F6> <ESC>:s=^\(//\)*==g<cr>:noh<cr>
Mar 15
BFS @ 2009-03-14
A,搜索,没做。
B,搜索,没做。
C,计算几何,没做。
D,加密算法,Boluor没做完。
E,模拟,Sandy写的,trick是需要先判断下一个走的人是谁(B/W)。
F,表达式的计算,我之前没有看题目,但是扫了一下,觉得应该很简单,回头写一下,应该不难吧。
G,计算几何,超简单的一个等比方程解一下;trick在于两个int加起来以后会OverFlow。
H,字符串处理,数据量很小,不要Trie,用map+set搞定。
I,没看。
J,DP,Sandy推出一个方程,和他讨论了一下,就被拖到机房去,然后他写了AC了。

oak真是相当的不堪阿,sigh。

--

党员活动室确实很适合看电影,音效非常好。

--

贴上我写的代码:
Mar 13
花了n久的时间终于搞清楚了,丫丫的,真麻烦

编译:
引用
g++ -Imysql/include -Lmysql/lib -o a.out a.cpp -lmysqlclient -lz

这个mysql目录是某个mysql的源码目录,如果有安装mysql-devel可能是在/usr/ooxx/mysql,没有的话自己去down源码

#include<iostream>
#include<string>
#include<fstream>
#include"mysql.h"
using namespace std;

MYSQL * conn = NULL; //MySQL连接句柄

//读取配置
bool read_conf(string &dbhost,
               string &dbuser,
               string &dbpass,
               string &dbname){
    ifstream is("judge.conf");
    is >> dbhost >> dbuser >> dbpass >> dbname;
    return true;
}

bool query(){
    int status, state, state2;
    MYSQL_RES * res;
    MYSQL_ROW   row;
    string cmd;
    MYSQL *conn, mysql;
    string dbhost, dbuser, dbpass, dbname;
    if(read_conf(dbhost,dbuser, dbpass, dbname)){ //读取数据库
        if (mysql_init(&mysql) == NULL){
            fprintf(stderr, "初始化错误\n");
            return false;
        }
        conn = mysql_real_connect(&mysql, dbhost.c_str(), dbuser.c_str(),
                              dbpass.c_str(), dbname.c_str(), NULL,
                              "/var/run/mysqld/mysqld.sock", 0);
        if(conn == NULL){ //连接失败
            fprintf(stderr, "连接失败!\n");
            return false;
        }
    }else{ //读取配置失败
        fprintf(stderr, "读取配置失败!\n");
        return false;
    }
    cmd = "SELECT OOXX FROM OOXX";
    cout << "Command: " << cmd << endl;
    state = mysql_query(conn, cmd.c_str());
    cout << "state: " << state << endl;
    if(state != 0){//查询出错
        fprintf(stderr, "%s\n", mysql_error(conn));
        return false;
    }
    res = mysql_store_result(conn);
    cout << "affected_rows:" << conn->affected_rows << endl;
    while(row = mysql_fetch_row(res), row != NULL){
        printf("%s\n", row[0]);
    }
    return true;
}

int main(){
    query();
    return 0;
}
Mar 12
简单写一下吧:
1. 自定义一个struct t,是set里要放的东西。
2. 定义一个仿函数cmper (仿函数functor,其实就是一个重载了operator()用于比较前述struct的类)。
3. 使用这样的语句: set<struct t, cmper> a; 来定义一个包含struct t的set容器。
4. 使用则样的语句: set<struct t, cmper>::iterator ap; 来定义一个对应的迭代器。

@ 2009-03-16补充:其实重载 bool operator < 也可以,就不需要仿函数了。

具体代码如下:
#include<iostream>
#include<set>
using namespace std;

struct t{  //set里的东西
    int i;  //可以再增加其他内容,为了简单只写了一个
    t(){i = 0;}          //构造函数
    t(int _i):i(_i){}    //构造函数
    friend inline ostream & operator <<(ostream &os, const t & a){  //重定向operator <<,纯粹是为了方便输出
        return (os << a.i);
    }
};

class cmper{  //仿函数
public:
    bool operator()(const t &a, const t &b)const{ //重载operator ()
        return a.i < b.i;
    }
};

set<t, cmper> a;  //定义一个set

int main(){
    a.insert(t(3));
    a.insert(t(1));
    a.insert(t(2));
    set<t, cmper>::iterator ap; //定义一个迭代器
    for (ap = a.begin(); ap != a.end(); ap++){ //遍历
        cout << (*ap) << endl;
    }
    return 0;
}

//重载example
struct t{
    int i;
    bool operator < (const t & a)const{
        return i < a.i;
    };
};
Mar 12
有两个版本,都很有意思。如果觉得看英文版郁闷,可以对照着google翻译看“中文版”:
http://translate.google.com/translate?prev=hp&hl=en&js=y&u=http%3A%2F%2Fwww.felix021.com%2Fblog%2Fread.php%3F1503&sl=en&tl=zh-CN&history_state0=

-------------------------------------------------------------

version 1 zz from http://topic.csdn.net/u/20070114/01/ee02dfed-511b-419a-91fe-89917726354a.html 7楼

  One day a Novice came to the Master.
  "Master, " he said, "How is it that I may become a Writer of Programs? ".
  The Master looked solemnly at the Novice.
  "Have you in your possession a Compiler of Source Code? " the Master asked.
  "No, " replied the Novice. The Master sent the Novice on a quest to the Store of Software.

  Many hours later the Novice returned.
  "Master, " he said, "How is it that I may become a Writer of Programs? ".
  The Master looked solemnly at the Novice.
  "Have you in your possession a Compiler of Source Code? " the Master asked.
  "Yes, " replied the Novice.
  The Master frowned at the Novice.
  "You have a Compiler of Source. What now can prevent you from becoming a Writer of Programs? ".
Mar 11
以后再不用雅黑了,这个字体一点也不比它差,而且还是开源的。
可以从这里下载: http://wenq.org/index.cgi?ZenHei

--

zz from http://linuxtoy.org/archives/wenqy-zenhei-0838.html

文泉驿正黑 0.8.38 (盘古) 正式发布
2009-03-06 Toy Posted in NewsRSS
开发代号为“盘古”的文泉驿正黑 0.8.38 版本已由文泉驿团队正式发布。
文泉驿团队成员 FangQ 在发布公告中写道:
Mar 9

最简单的播放器,嗯。 不指定

felix021 @ 2009-3-9 20:41 [IT » 软件] 评论(2) , 引用(0) , 阅读(5930) | Via 本站原创
引用
felix021@felix021-laptop:~ $ gst-launch-0.10 filesrc location="JingleBells.wma" ! decodebin ! alsasink
Mar 9

POJ 不指定

felix021 @ 2009-3-9 16:43 [IT » 程序设计] 评论(2) , 引用(0) , 阅读(6337) | Via 本站原创
前些天从某网站下载到了POJ的程序(不是源码) ( @ http://www.dssz.com/250473.html )
要1个积分的。1个积分要1个大洋的。一次性最少充10个积分的。于是我就少了10个大洋。于是就down到了POJ。
down下来是12MB,解压后大几十MB,发现里面带有一个3.4.2版的gcc,40+MB,Orz。去掉那个gcc打包,2MB。
在自己机器上架起来了。Windows(XP) + Tomcat(5.5.27) + JDK(6)。可以正常运行。
反正某一次我去申请了,填了个表,但是PKU那边根本没回复。
刚刚到POJ上面去看了一遍,貌似以前的申请已经被通过了,再次点开那个页面就可以下载了,我囧。
下载下来一看,12.9MB,gcc还是3.4.2。原来是我浪费了10个大洋。

down下来的包里面有一个license.txt,全英文的(真无聊。。),之前down下来懒得看
这回直接贴到translate.google.com,然后看到超搞笑的翻译:

引用
...the source code of the Software.  ----  ...源代码的软件

引用
5. LIMITATION OF LIABILITY
In no event will PKU ACM Team be liable for any damages, including but not limited to any loss of revenue, profit, or data, however caused, directly or indirectly, by the Software or by this Agreement. 
5 。责任限制
在任何情况下,北京大学计算机小组须承担任何赔偿,包括但不限于任何损失的营业收入,利润,或数据,但是造成的直接或间接的软件或通过本协定。

看来那个站点还是违反的这个license的,嗯。

看到第六点:
引用
6. DISTRIBUTION
No distribution is to be made of the Software by the Licensee.  The Licensee may make one copy of the Software for backup purpose only.
//Google的翻译
6 。分布
没有分配将软件由持牌人。持牌人可一复制的软件,如备份用途。


看来还是不允许随便流传的。。。
分页: 2/3 第一页 上页 1 2 3 下页 最后页 [ 显示模式: 摘要 | 列表 ]