Created
August 21, 2012 09:15
-
-
Save linmx0130/3413821 to your computer and use it in GitHub Desktop.
USACO Data Getter - if the zip file is wrong, this program will help you to get get the data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdio> | |
| #include <string> | |
| #define PRONAME "fishing" | |
| char buf[1024]; | |
| std::string newfilename; | |
| std::string int2string(int d) | |
| { | |
| std::string ret; | |
| while (d) | |
| { | |
| ret+=d%10+'0'; | |
| d/=10; | |
| } | |
| for (int i=0;i<ret.size()>>1;++i) | |
| { | |
| char k=ret[i]; | |
| ret[i]=ret[ret.size()-1-i]; | |
| ret[ret.size()-1-i]=k; | |
| } | |
| return ret; | |
| } | |
| int main() | |
| { | |
| int nowd=0; | |
| while (1) | |
| { | |
| gets(buf); | |
| if (buf[0]=='\0') continue; | |
| if (buf[0]=='E') break; | |
| if (buf[0]=='I') | |
| { | |
| fclose(stdout); | |
| ++nowd; | |
| newfilename=PRONAME; | |
| newfilename+=int2string(nowd); | |
| newfilename+=".in"; | |
| freopen(newfilename.c_str(),"w",stdout); | |
| continue; | |
| } | |
| if (buf[0]=='O') | |
| { | |
| fclose(stdout); | |
| newfilename=PRONAME; | |
| newfilename+=int2string(nowd); | |
| newfilename+=".out"; | |
| freopen(newfilename.c_str(),"w",stdout); | |
| continue; | |
| } | |
| puts(buf); | |
| } | |
| fclose(stdout); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment