代码高亮测试。。。
c++吧
全部回复
仅看楼主
level 11
gameloftyou 楼主
#include <windows.h>
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <cstdlib>
using 
namespace std;
string mn;
void toLower(string &s)
{
    
for(string::iterator iter=s.begin();iter!=s.end();++iter)
    {
        *iter = tolower(*iter);
    }
}
inline 
bool startswith(string &a,string &b)
{
    
if(a.size()<b.size())
    {
        
return 
false;
    }
    
return a.substr(0,b.size())==b;
}
void doObj(string &fp,string &fn,string &nd)
{
    ifstream in(fp.c_str());
    ofstream out((nd+"\\"+fn+".obj").c_str());
    string usemtl("usemtl"),f("f"),mtllib("mtllib"),now,pre;
    
int c = 0;
    
    
while(getline(in,now))
    {
        now+="\n";
        
if(startswith(now,usemtl)&&startswith(pre,f))
        {
            out<<"o "<<c<<"\n";
            out<<now;
        }
        
else 
if(startswith(now,mtllib))
        {
            istringstream is(now);            
            is>>mn>>mn;
            out<<now;
        }
        
else
        {

2012年09月12日 13点09分 1
level 11
gameloftyou 楼主
#ifndef 
CACHEDOBJ_H_INCLUDED
#define 
CACHEDOBJ_H_INCLUDED
#include 
<
cstddef
>
#include 
<
memory
>
#include 
<
stdexcept
>
template <
class T> 
class CachedObj {
public:
    
void *
operator 
new(std::size_t);
    
void 
operator 
delete(
void *,std::size_t);
    
virtual ~CachedObj(){}
protected:
    T *next;
    
private:
    
static 
void add_to_freelist(T *);
    
static std::allocator<T> alloc_mem;
    
static T *freeStore;
    
static 
const std::size_t chunk;
    
};
#include 
"
CachedObj
.
cpp
"
#endif
 
2012年09月14日 01点09分 7
level 11
gameloftyou 楼主
#ifndef CACHEDOBJ_H_INCLUDED
#define CACHEDOBJ_H_INCLUDED
#include <cstddef>
#include <memory>
#include <stdexcept>
template <
class T> 
class CachedObj {
public:
    
void *
operator 
new(std::size_t);
    
void 
operator 
delete(
void *,std::size_t);
    
virtual ~CachedObj(){}
protected:
    T *next;
    
private:
    
static 
void add_to_freelist(T *);
    
static std::allocator<T> alloc_mem;
    
static T *freeStore;
    
static 
const std::size_t chunk;
    
};
#include "CachedObj.cpp"
#endif
 
2012年09月14日 01点09分 8
蓝字有链接蛋疼[囧]
2012年09月14日 01点09分
level 13
不好看
2012年09月14日 02点09分 9
[揉脸]
2012年09月14日 02点09分
level 11

2012年09月14日 02点09分 10
level 8
蓝字会被封号的~
2012年09月14日 13点09分 29
[揉脸]
2012年09月14日 14点09分
level 10
有现成的了?那我就不写了。[汗]
2012年09月14日 14点09分 33
现在贴吧好像不能发无链接蓝字了[囧],而且实际上一个贴中的<strong></strong>和<span class=\"edit_font_color\"></span>的使用次数也是有限制的,所以要发大量格式代码的话就要考虑优化算法了。[揉脸]
2012年09月14日 14点09分
回复 gameloftyou :那个早不能发了,不过可以https://tieba.baidu.com/p/17764636162L的方法。代码高亮正在写算法,html这块暂时还没看……[汗]求支援。
2012年09月14日 14点09分
1