大概可以拿来方便拉模板

变量名、语法都是瞎整的你感觉有用随便用好了..

#include<bits/stdc++.h>
using namespace std;
map<string,int>fp;
inline bool is_space(char c){return c==' '||c=='\t';}
bool Strike(char*t,int len,const char*strpat){
for(int i=0;i<len;++i)
if(t[i]!=strpat[i])
return 0;
return 1;
}
void Copy_File(const char*filename,char*intd){
FILE*inFile=fopen(filename,"r");
char*Line_Buffer=new char[1<<20];
while(!feof(inFile)&&fgets(Line_Buffer,1<<20,inFile)){
// process line
printf("%s%s",intd,Line_Buffer);
}puts("");
}
void Process_File(const char*filename){
int len=strlen(filename);
string filename_string(filename,len);
if(fp[filename])return;
fp[filename]=1; FILE*inFile=fopen(filename,"r");
char*Line_Buffer=new char[1<<20];
char*Intend_Buffer=new char[1<<20]; while(!feof(inFile)&&fgets(Line_Buffer,1<<20,inFile)){
// process line
int len=strlen(Line_Buffer),int_siz=0,i=0;
for(;i<len;++i)
if(is_space(Line_Buffer[i]))
Intend_Buffer[int_siz++]=Line_Buffer[i];
else break;
if(Strike(Line_Buffer+i,5,"//cp_")){
// cp detected
if(Strike(Line_Buffer+i+5,8,"REQUIRE<")){
int t=i+13,z=0;
while(t<len&&Line_Buffer[t]!='>')++t,++z;
char*FileName=new char[z+2];
memcpy(FileName,Line_Buffer+i+13,z);
FileName[z]=0;
Process_File(FileName);
}else if(Strike(Line_Buffer+i+5,7,"INJECT<")){
int t=i+12,z=0;
while(t<len&&Line_Buffer[t]!='>')++t,++z;
char*FileName=new char[z+2];
memcpy(FileName,Line_Buffer+i+12,z);
FileName[z]=0;
Copy_File(FileName,Intend_Buffer);
}else printf("%s",Line_Buffer);
}else printf("%s",Line_Buffer);
}puts("");
}
int main(int argc,const char**argv){
if(argc<=1)
return puts("Usage: [exec_name] \"FileName\""),0;
Process_File(argv[1]);
// Process_File("cppptest1.cpp");
return 0;
}

C++ Contest Code preprocessor的更多相关文章

  1. WAVE文件格式解析

    WAVE 文件作为Windows多媒体中使用的声音波形文件格式之一,它是以RIFF(Resource Interchange File Format)格式为标准的.这里不针对RIFF文件格式做介绍,不 ...

  2. HDU 2096 小明A+B(%的运用)

    传送门: 小明A+B Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  3. 推荐一篇讲arm架构gcc内联汇编的文章

    这是来自ethernut网站的一篇文章,原文链接: http://www.ethernut.de/en/documents/arm-inline-asm.html 另外,据说nut/os是个不错的开源 ...

  4. YASM User Manual

    This document is the user manual for the Yasm assembler. It is intended as both an introduction and ...

  5. IOCCC(The International Obfuscated C Code Contest)

    国际 C 语言混乱代码大赛(IOCCC, The International Obfuscated C Code Contest)是一项国际编程赛事,从 1984 年开始,每年举办一次(1997年.1 ...

  6. 2015 Multi-University Training Contest 7 hdu 5375 Gray code

    Gray code Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  7. DISCO Presents Discovery Channel Code Contest 2020 Qual Task E. Majority of Balls

    Not able to solve this problem during the contest (virtual participation). The first observation is ...

  8. The North American Invitational Programming Contest 2018 E. Prefix Free Code

    Consider nn initial strings of lower case letters, where no initial string is a prefix of any other ...

  9. hdu 3461 Code Lock(并查集)2010 ACM-ICPC Multi-University Training Contest(3)

    想不到这还可以用并查集解,不过后来证明确实可以…… 题意也有些难理解—— 给你一个锁,这个所由n个字母组成,然后这个锁有m个区间,每次可以对一个区间进行操作,并且区间中的所有字母要同时操作.每次操作可 ...

随机推荐

  1. C# 运用作用域

    前面已经展示了一些在方法内部创建变量的例子.变量从定义了它的语句开始存在,同一个方法内的后续语句可以使用该变量.换言之,变量只能在创建了之后才能使用.方法执行完毕后,变量也会彻底消失. 假如一个变量能 ...

  2. Oracle Undo 和 Redo

    1. REDO(重做信息) Redo log file(重做日志文件),是数据库的事务日志. Oracle维护着两类重做日志文件:在线(online)重做日志文件和归档(archived)重做日志文件 ...

  3. 稍微深入点理解C++复制控制【转】

    通过一个实例稍微深入理解C++复制控制过程,参考资料<C++ primer>,介绍点基本知识: 1.在C++中类通过特殊的成员函数:复制构造函数.赋值操作符和析构函数来控制复制.赋值和撤销 ...

  4. popen和pclose详解及实例

    popen函数是标准c提供的一个管道创建函数,其内部操作主 要是创建一个管道,调用fork创建子进程,关闭不需用的文件描述符,调用exec函数族执行popen的第一个参数.然后等到关闭. 也就是说我们 ...

  5. 洛谷P1049装箱问题

    一句话刚刚的题会了,这题能不会么. #include<bits/stdc++.h> using namespace std; int main(){ int n,m; cin>> ...

  6. Java - 类加载的时候,是有缺省同步锁的

    类加载的时候,是有缺省同步锁的

  7. MySql主从同步笔记

    1.MySql主从同步是基于二进制日志实现的,二进制日志记录了主服务器数据库的所有变动,从服务器通过读取和执行该日志文件保持和主数据库的数据一致: 2.配置主服务器 a.开启二进制日志,找到MySql ...

  8. 火狐IE event和target的兼容

    一.event对象 IE 中可以直接使用 window.event 对象,而 FF 中则不可以,解决方法之一如下: var theEvent = window.event || arguments.c ...

  9. 大数据的存储——HBase、HIVE、MYSQL数据库学习笔记

    HBase 1.hbase为查询而生,它通过组织机器的内存,提供一个超大的内存hash表,它需要组织自己的数据结构,表在hbase中是物理表,而不是逻辑表,搜索引擎用它来存储索引,以满足实时查询的需求 ...

  10. html5定位获取当前位置并在百度地图上显示

    用html5的地理定位功能通过手机定位获取当前位置并在地图上居中显示出来,下面是百度地图API的使用过程,有需要的朋友可以参考下 在开发移动端 web 或者webapp时,使用百度地图 API 的过程 ...