在编写c++程序时,我们通常使用标准输入输出流,也就是键盘为输入,屏幕为输出。但有时我们希望从文件输入或者输出到文件,比如在做acm题时为了避免反复人工输入的麻烦。解决这一问题的快速方法是,在你的main函数中加入如下代码:
#ifndef ONLINE_JUDGE
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt+",...
分类:
编程语言 时间:
2014-07-23 16:38:52
阅读次数:
236
暴力搜索 1 #include 2 3 struct node 4 { 5 int x; 6 int y; 7 }s[10000]; 8 int main() 9 {10 //freopen("input.txt","r",stdin);11 int a,b,n,n...
分类:
其他好文 时间:
2014-07-23 11:58:36
阅读次数:
293
map的应用 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int main() 7 { 8 freopen("input.txt","r",stdin); 9 mapballoons;10 ...
分类:
其他好文 时间:
2014-07-23 11:57:26
阅读次数:
205
set的应用 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int main() 7 { 8 freopen("input.txt","r",stdin); 9 string s,s1;10 ...
分类:
其他好文 时间:
2014-07-23 11:56:56
阅读次数:
226
一道贪心题,尽量横着切或竖着切,实在不行在交叉切
#include
#include
using namespace std;
int main(){
// freopen("in.txt","r",stdin);
long long n,m,k;
while(cin>>n>>m>>k){
if((n+m-2)<k){
printf...
分类:
其他好文 时间:
2014-07-22 22:38:53
阅读次数:
160
刚做这道题根本没想到二分,最关键是没想出来如何统计在这个矩阵中比一个数小的有几个怎么算,造成自己想了好久最后看了别人的提示才做出来。哎!好久不做题太弱了
#include
#include
using namespace std;
int main(){
// freopen("in.txt","r",stdin);
long long n,m,k;
while(cin>>...
分类:
其他好文 时间:
2014-07-22 22:33:55
阅读次数:
192
挺水的一道题,规律性很强,在数组中找出最大的数max,用max/m计算出倍数t,然后再把数组中的书都减去t*m,之后就把数组从后遍历找出第一个大于零的就行了
#include
#include
using namespace std;
int main(){
// freopen("in.txt","r",stdin);
int a[105],n,m;
while(~sca...
分类:
其他好文 时间:
2014-07-21 23:29:23
阅读次数:
312
1、打开外部程序1.1os.system—>发送命令,让系统执行,没有返回值os.popen—>可执行系统命令,可以获取标准输出lll=os.popen(‘ls’)lll.read()os.popen2—>元组方式返回标准输入和标准输出stdin,stdou=os.popen2(‘sort’)s=‘’’ecdbe’’stdin.write(s)stdin.clo..
分类:
编程语言 时间:
2014-07-21 19:27:02
阅读次数:
322
1、sys.stdin为文件对象,当对文件对象做循环的时候,返回的为行数2、ls>log2>&1标准输出和标准错误都输出到log,&>log也可以,但是会有版本限制3、print和stdout的区别:print是调用一个对象的write方法,通常是stdoutprint会先进行格式转换print123456==sys..
分类:
编程语言 时间:
2014-07-21 19:24:02
阅读次数:
251
立方算法:
#include
#include
#include
#include
#define M 505
using namespace std;
typedef long long LL;
LL a[M],b[M];
int dp[M][M];
int main()
{
//freopen("in.txt","r",stdin);
int T;
cin>>T;
...
分类:
其他好文 时间:
2014-07-20 23:01:50
阅读次数:
284