同路径下生成要求的名字.cpp 和.in,可以把数据存进去。
改下XXX YYY就能用了patpat
只是因为太懒,望天
#include <bits/stdc++.h> using namespace std; string op; int main(){ cin >> op; freopen((op+".cpp").c_str() , "w", stdout); cout<<"/*"<<endl<<"ID: XXXXXXXXXXXXXXX"<<endl; cout<<"PROG: "<<op<<endl; cout<<"LANG: C++"<<endl<<"*/"<<endl; cout<<"#include <bits/stdc++.h>"<<endl<< "using namespace std;"<<endl; cout<<"int main()"<<endl<<"{"<<endl; cout<<"\tfreopen(\""+op+".in\","+"\"r\","+"stdin);"<<endl; cout<<"\t#ifndef YYYYY"<<endl; cout<<"\tfreopen(\""+op+".out\","+"\"w\","+"stdout);"<<endl; cout<<"\t#endif"<<endl; cout<<"}"<<endl; freopen((op+".in").c_str(), "w", stdout); //cout<<"!!"<<endl; return 0; }
原文:http://www.cnblogs.com/bbbbbq/p/4646592.html