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.

13 tháng 3 2021

Program HOC24;

const fi='DULIEU.DAT';

fo='KETQUA.DAT';

var a,x,n: integer;

s: longint;

function luythua(a,b: integer): longint;

var j,t: longint;

begin

t:=1;

for j:=1 to b do t:=t*a;

luythua:=t;

end;

procedure ip;

begin

assign(f,fi);

reset(f);

read(f,a,x,n);

close(f);

end;

procedure out;

begin

assign(f,fo);

rewrite(f);

s:=1;

for i:=1 to n do

s:=s+luythua(x,i)*(a+i);

write(f,s);

close(f);

end;

begin

ip;

out;

end.

const fi='dulieu.dat';

fo='ketqua.dat';

var f1,f2:text;

n,i,s:integer;

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

begin

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

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

n:=0;

while not eof(f1) do 

  begin

n:=n+1;

read(f1,a[n]);

end;

s:=0;

for i:=1 to n do 

  s:=s+a[i];

writeln(f2,s);

close(f1);

close(f2);

end.

#include <bits/stdc++.h>

using namespace std;

long long a[10],b[10],i,j;

int main()

{

freopen("input.txt","r",stdin);

freopen("output.txt","w",stdout);

for (i=1; i<=10; i++) cin>>a[i];

for (j=1; j<=10; j++) cin>>b[j];

for (i=1; i<=10; i++)

cout<<a[i]+b[i]<<" ";

return 0;

}

uses crt;

const fi='dulieu.txt';

var f1:text;

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

t:real;

i,n:integer;

begin

clrscr;

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

readln(f1,n);

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

t:=0;

for i:=1 to n do t:=t+a[i];

writeln(t);

close(f1);

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long a,b;

int main()

{

freopen("dulieu.txt","r",stdout);

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

cin>>a>>b;

cout<<a+b;

return 0;

}

uses crt;

const fi='mang.txt';

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

i,n,t1,t2:integer;

f1:text;
begin

clrscr;

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

write('Nhap n='); readln(n);

for i:=1 to n do 

  begin

write('A[',i,']='); readln(a[i]);

end;

t1:=0;

t2:=0;

for i:=1 to n do 

  begin

if a[i]>0 then 

begin

t1:=t1+a[i];

end;

if a[i]<0 then

begin

t2:=t2+a[i];

end;

end;

writeln(f1,'Tong cac so duong la: ',t1);

writeln(f1,'Tong cac so am la: ',t2);

if abs(t1)>abs(t2) then writeln(f1,'Gia tri tuyet doi cua ',t1,' lon hon gia tri tuyet doi cua ',t2)

else if abs(t1)<abs(t2) then writeln(f1,'Gia tri tuyet doi cua ',t2,' lon hon gia tri tuyet doi cua ',t1)

else writeln(f1,'Gia tri tuyet doi cua ',t1,' bang gia tri tuyet doi cua ',t2);

close(f1);

end.

23 tháng 2 2022

ko bt 

 

Câu 2:

uses crt;

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

i,n,t:integer;

begin

clrscr;

randomize;

cin>>n;

for i:=1 to n do a[i]:=random(500);

t:=0;

for i:=1 to n do if a[i]=150 then t:=t+a[i];

writeln(t);

readln;

end.

const fi='bai25.inp';

fo='bai25.out';

var f1,f2:text;

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

i,n,dem,dem1,d:integer;

kt:boolean;

begin

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

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

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

dem:=0;

dem1:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then inc(dem)

else inc(dem1);

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

writeln(f2,'So luong so le la: ',dem1);

d:=abs(a[2]-a[1]);

kt:=true;

for i:=2 to n do

  if abs(a[i]-a[i-1])<>d then

begin

kt:=false;

break;

end;

if kt=true then writeln(f2,'Day la day cap so cong')

else writeln(f2,'Day khong la day cap so cong');

close(f1);

close(f2);

end.