[cao题解专用]注释消失术&&三字母词转换器
Dragon_Knight · · 个人记录
upd on 10/2:新增三字母词转换器 upd on 10/1:更新使用方法,支持haskell,c#
upd on 9/27:批量版提取码:czsb(真·自动生成)持续更新
upd on 2021/9/26 支持c++,c,java,python,pascal,ruby,rust,python
upd:2021/9/25 摆脱new.cpp困扰
2021/9/23更新:修复bug,加入格式功能
注释消失术
Usage:
实例:zsxss.exe xxx.cpp xxx.py xxx.hs
#include<bits/stdc++.h>
#include<windows.h>
#pragma GCC opitmized(3,"Ofast","inline")
#define r register
#define ini inline
using namespace std;
int main(int argc,char* argv[])
{
for(int i=1; i<argc; i++)
{
string s;
int f=0,f1=0,f2=0;
s=argv[i];
int sx=0;
while(s[sx]!='.') sx++;
sx++;
string sa;
for(; sx<s.length(); sx++) sa+=s[sx];
if(sa=="cs"||sa=="cpp"||sa=="h"||sa=="c"||sa=="hpp"||sa=="java"||sa=="cxx"||sa=="hxx"||sa=="rs")
{
freopen(s.c_str(),"r",stdin);
system("@echo off\ndel tmp");
freopen("tmp","w",stdout);
string s2;
while(getline(cin,s2))
{
for(int i=0; i<s2.length(); i++)
{
if(s2[i]=='/'&&s2[i+1]=='/')
{
f1=1;
break;
}
else if(s2[i]=='/'&&s2[i+1]=='*')
{
f2=1;
f=1;
i+=2;
}
if(s2[i]=='*'&&s2[i+1]=='/')
{
f=0;
i+=2;
}
if(f) continue;
cout<<s2[i];
}
cout<<endl;
}
freopen("CON","w",stdout);
cout<<"DONE\n";
Sleep(1000);
fclose(stdin);
string sn="del ";
sn+=s;
system(sn.c_str());
sn="ren tmp ";
sn+=s;
system(sn.c_str());
}
else if(sa=="py")
{
freopen(s.c_str(),"r",stdin);
system("@echo off\ndel tmp");
freopen("tmp","w",stdout);
string s2;
while(getline(cin,s2))
{
for(int i=0; i<s2.length(); i++)
{
if(s2[i]=='#')
{
f1=1;
break;
}
else if(f==0&&(s2[i]=='\''&&s2[i+1]=='\''&&s2[i+2]=='\''||s2[i]=='\"'&&s2[i+1]=='\"'&&s2[i+2]=='\"'))
{
f2=1;
f=1;
i+=3;
}
if(f==1&&(s2[i]=='\''&&s2[i+1]=='\''&&s2[i+2]=='\''||s2[i]=='\"'&&s2[i+1]=='\"'&&s2[i+2]=='\"'))
{
f=0;
i+=3;
}
if(f) continue;
cout<<s2[i];
}
cout<<endl;
}
freopen("CON","w",stdout);
cout<<"DONE\n";
Sleep(1000);
fclose(stdin);
string sn="del ";
sn+=s;
system(sn.c_str());
sn="ren tmp ";
sn+=s;
system(sn.c_str());
}
else if(sa=="pas")
{
freopen(s.c_str(),"r",stdin);
system("@echo off\ndel tmp");
freopen("tmp","w",stdout);
int ff=0;
string s2;
while(getline(cin,s2))
{
for(int i=0; i<s2.length(); i++)
{
if(s2[i]=='/'&&s2[i+1]=='/')
{
f1=1;
break;
}
else if(s2[i]=='('&&s2[i+1]=='*')
{
f2=1;
f=1;
i+=2;
}
else if(s2[i]=='*'&&s2[i+1]==')')
{
f=0;
i+=2;
}
else if(s2[i]=='{') ff=1,i++;
else if(s2[i]=='}') ff=0,i++;
if(f||ff) continue;
cout<<s2[i];
}
cout<<endl;
}
freopen("CON","w",stdout);
cout<<"DONE\n";
Sleep(1000);
fclose(stdin);
string sn="del ";
sn+=s;
system(sn.c_str());
sn="ren tmp ";
sn+=s;
system(sn.c_str());
}
else if(sa=="rb")
{
freopen(s.c_str(),"r",stdin);
system("@echo off\ndel tmp");
freopen("tmp","w",stdout);
string s2;
while(getline(cin,s2))
{
for(int i=0; i<s2.length(); i++)
{
if(s2[i]=='#')
{
f1=1;
break;
}
else if(f==0&&(s2.substr(i,6)=="=begin"))
{
f2=1;
f=1;
i+=6;
}
if(f==1&&(s2.substr(i,4)=="=end"))
{
f=0;
i+=4;
}
if(f) continue;
cout<<s2[i];
}
cout<<endl;
}
freopen("CON","w",stdout);
cout<<"DONE\n";
Sleep(1000);
fclose(stdin);
string sn="del ";
sn+=s;
system(sn.c_str());
sn="ren tmp ";
sn+=s;
system(sn.c_str());
}
else if(sa=="hs"||sa=="lhs")
{
freopen(s.c_str(),"r",stdin);
system("@echo off\ndel tmp");
freopen("tmp","w",stdout);
string s2;
while(getline(cin,s2))
{
for(int i=0; i<s2.length(); i++)
{
if(s2[i]=='-'&&s2[i+1]=='-')
{
f1=1;
break;
}
else if(s2[i]=='{'&&s2[i+1]=='-')
{
f2=1;
f=1;
i+=2;
}
if(s2[i]=='-'&&s2[i+1]=='}')
{
f=0;
i+=2;
}
if(f) continue;
cout<<s2[i];
}
cout<<endl;
}
freopen("CON","w",stdout);
cout<<"DONE\n";
Sleep(1000);
fclose(stdin);
string sn="del ";
sn+=s;
system(sn.c_str());
sn="ren tmp ";
sn+=s;
system(sn.c_str());
}
else cout<<"This program can only allow C++,C,Java,Ruby,C#,Rust,Haskell,Pascal and Python source files.";
}
}
三字母词转换器
介绍
三字母词类似转义字符,在C++中,若程序出现三字母词,则编译器会自动替换相应的字符。
#include<bits/stdc++.h>
#pragma GCC opitmized(3,"Ofast","inline")
using namespace std;
int main()
{
cout<<"Input file name:____________\b\b\b\b\b\b\b\b\b\b\b\b";
string s;
cin>>s;
freopen(s.c_str(),"r",stdin);
system("@echo off\ndel ~$tmp");
freopen("~$tmp","w",stdout);
int c;
while((c=getchar())!=EOF)
{
if(c=='#')
{
cout<<"??"<<'=';
continue;
}
if(c=='{')
{
cout<<"??"<<'<';
continue;
}
if(c=='}')
{
cout<<"??"<<'>';
continue;
}
if(c=='[')
{
cout<<"??"<<'(';
continue;
}
if(c==']')
{
cout<<"??"<<')';
continue;
}
if(c=='\\')
{
cout<<"??"<<'/';
continue;
}
cout<<(char)(c);
}
fclose(stdin);
freopen("CON","w",stdout);
string s3="del ";
s3+=s;
system(s3.c_str());
s3="ren ~$tmp ";
s3+=s;
system(s3.c_str());
cout<<"DONE";
}