K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

12 tháng 4 2019

Lời giải :

program hotrotinhoc ;

cont a ='sn.inp' ;

b ='sn.out' ;

var

f: text ;

i,n,S,T : integer ;

begin

assign(a,f);

reset(f);

read(f,n);

close(f);

assign(b,f);

rewrite(f);

S:=0;

for i:=1 to n do

if i mod 2= 0 then S:=S+i;

writeln(f,'Tong cac so chan la',S);

for i:= 1 to n do

if i mod 2=1 then T:=T+i ;

writeln(f,'Tong cac so chan la ',T);

close(f);

end.

const fi='sn.inp';

fo='sn.out';

var f1,f2:text;

a,b:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,a,b);

writeln(f2,a-b);

close(f1);

close(f2);

end.

const fi='sn.inp';

fo='sn.out';

var f1,f2:text;

a,b:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,a,b);

writeln(f2,a-b);

close(f1);

close(f2);

end.

const fi='bai1.inp';

fo='bai1.out';

var f1,f2:text;

a:array[1..100]of integer;

n,i,t,dem:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

t:=0;

dem:=0;

for i:=1 to n do 

  begin

if a[i] mod 2<>0 then t:=t+a[i]

else inc(dem);

end;

writeln(f2,'Tong cac so le la: ',t);

writeln(f2,'So so chan la: ',dem);

close(f1);

close(f2);

end.

3 tháng 5 2021

Uses crt;

Var i,n,tong:integer;

      a:array[1..10000] of integer;

      f1,f2:text;

Begin

clrscr;

Assign(f1,'tinhtong.inp');

Assign(f2,'tinhtong.out');

tong:=0;

Reset(f1);readln(f1,n);

For i:= 1 to n do

Begin

read(f1,a[i]);

tong:=tong+a[i];

End;

close(f1);

rewrite(f2);

Writeln(f2,tong);

Readln;

End.

3 tháng 5 2021

Chị bổ sung dùm em thêm câu lệnh đóng file f2 nữa nha

 

30 tháng 12 2021

1:

uses crt;

const fi='songuyen.doc';

var i:integer;

f1:text;

begin

clrscr;

assign(f1,fi); rewrite(f1);

for i:=1 to 10 do write(f1,i:4);

close(f1);

readln;

end.

uses crt;

const fi='songuyen.inp';

fo='songuyen2.out';

var a:array[1..100]of integer;

i,n,t1:integer;

f1,f2:text;

begin

clrscr;

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do readln(f1,a[i]);

t1:=0;

for i:=1 to n do if a[i] mod 2<>0 then t1:=t1+a[i];

writeln(t1);

writeln(f2,t1);

for i:=1 to n do 

  if a[i] mod 2<>0 then write(a[i]:4);

close(f1);

close(f2);

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long a,b;

double tb;

int main()

{

freopen("dulieu.inp","r",stdin);

freopen("ketqua.out","w",stdout);

cin>>a>>b;

cout<<a<<" "<<b;

cout<<fixed<<setprecision(2)<<(a*1.0+b*1.0)/(2*1.0);

return 0;

}