| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:问: 怎么设置文件读 写??In Reply To:Re:问: 怎么设置文件读 写?? Posted by:shiming413 at 2006-01-05 20:02:56 这个很简单的, 例如你将题目的 input 复制到一个 文本文档 a.in 中
那么
int main()
{
#ifndef JUDGE
freopen("a.in", "r", stdin);
freopen("t.out", "w", stdout);
#endif
...
...
}
就是从文件a.in中读入,输出到t.out中,不需要你手动输入,
而如果你想手动输入,只要将 ifndef 变为 ifdef 就OK了。很是方便
如果使用C++的fstream, 那么还要该名称,烦噢。
不知道C++中怎么直接绑定文件输入输出到 cin, cout上??
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator