对拍

测试数据文件:

#include<cstdio>  
#include<cstring>  
#include<ctime>  
#include<cstdlib> 
#include <iostream>
using namespace std; 
int main(void)  
{   
    freopen("in.txt","w",stdout);  
    srand(time(NULL));  
    int n=1000;//测试数据数量 
    while(n--)  
    { 
	cout<<rand()%1000<<" "<<rand()%1000<<endl;
    	//printf("%d\n",rand());  
    }  
    fclose(stdout);
    return 0;  
}  

标准程序:

//#include <cstdio> 
#include <iostream> 
using namespace std;
int main() 
{ 
	int a,b; 
	freopen("in.txt","r",stdin); //输入重定向,输入数据将从in.txt文件中读取 
	freopen("out1.txt","w",stdout); //输出重定向,输出数据将保存在out.txt文件中 
	while(cin>>a>>b){
		cout<<a+b<<endl; // 注意使用endl 
	}
	fclose(stdin);//关闭文件 
	fclose(stdout);//关闭文件 
	return 0; 	
} 
测试程序:
//#include <cstdio> 
#include <iostream> 
using namespace std;
int main() 
{ 
	int a,b; 
	freopen("in.txt","r",stdin); //输入重定向,输入数据将从in.txt文件中读取 
	freopen("out2.txt","w",stdout); //输出重定向,输出数据将保存在out.txt文件中 
	while(cin>>a>>b){
		if(a<5)
			cout<<a+b<<endl; // 注意使用endl 
		else
			cout<<a*b<<endl;
	
	}
	fclose(stdin);//关闭文件 
	fclose(stdout);//关闭文件 
	return 0; 	
} 

创建bat文件,输入

fc out1.txt out2.txt      
pause
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值