点击这里更换您喜欢的皮肤wtboj 首页
请点击这里登入noios   首页 入门 c++讲义 入门教程视频 金牌教程 入门视频 站务 公告 | 题库 记录 竞测 测试 闯关 作业 排名 团队 讨论 | 换肤 | 登入 注册  
News >>   新增功能:各团队管理员可以发布本团队作业了 ()

讨论 Discussion
 
78
文件读写格式例题:
编号为p1000的求两个数的和的free pascal c++ c 三种语言解答样例:
C++ Code:
-------------------
#include <bits/stdc++.h>
using namespace std;
int main(){  
 freopen("p1000.in","r",stdin);
 freopen("p1000.out","w",stdout);
 int a,b;  
 cin>>a>>b;  
 cout<<a+b<<endl;  
 fclose(stdin);
 fclose(stdout);
 return 0;
}

Free Pascal Code:
-------------------
var a,b:longint;
begin
 assign(input,'p1000.in');
 assign(output,'p1000.out');
 reset(input);
 rewrite(output);
 readln(a,b);
 writeln(a+b);
 close(input);
 close(output);
end.

C Code:
-------------------
#include<stdio.h>
#include<stdlib.h>
int main(){
int a,b,c;
FILE *fin = fopen("P1000.in","r");
FILE *fout = fopen("P1000.out","w+");
fscanf(fin,"%d%d",&a,&b);
c=a+b;
fprintf(fout,"%d",c);
close(fin);
close(fout);
return 0;
}
( )

此主题无回复显示
发布讨论主题 回复讨论主题
 Copyright wtboj © 2005-2006. www.wutuobang.date Powered by wtboj 关于 联系 帮助
 wtboj Information ---- Total Users : 1365 | Online Users / Processes : 0 / 48 | Processed Time : 423 ms | Server Time : 2026/1/10 2:05:44