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.

uses crt;

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

n,i,k,t:integer;

begin

clrscr;

repeat

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

until (0<n) and (n<=100);

for i:=1 to n do

begin

repeat

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

until abs(a[i])<=300;

end;

write('nhap k='); readln(k);

t:=0;

for i:=1 to n do

if a[i] mod k=0 then t:=t+a[i];

writeln('Tong cac so la boi cua ',k,' trong day la: ',t);

readln;

end.

Đề thiếu rồi bạn

19 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

long long a[20],b[20],c[20],i,n;

int main()

{

cin>>n;

srand(time(NULL));
    for (i=1; i<=n; i++)
      a[i]=rand();

srand(time(NULL));
    for (i=1; i<=n; i++)
      b[i]=rand();

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

c[i]=abs(a[i]-b[i]);

for (i=1; i<=n; i++) cout<<a[i]<<" "; cout<<endl;

for (i=1; i<=n; i++) cout<<b[i]<<" "; cout<<endl;

for (i=1; i<=n; i++) cout<<c[i]<<" "; cout<<endl;

return 0;

}

26 tháng 5 2017

uses crt;
const finp='nhap.txt';
fout='xuat.txt';
type mang=array[1..10000] of longint;
var f:text;
n:longint;
a:mang;

{-----------------------------------------------------}
procedure doc;
var i:longint;
begin
assign(f,finp);
reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]);
close(f);
end;

{-----------------------------------------------------------------}
procedure ghi;
begin
assign(f,fout);
rewrite(f);
end;

{--------------------------------------------------------------}
function scp(x:longint):boolean;
begin
if sqr(round(sqrt(x)))=x then scp:=true
else scp:=false;
end;

{-------------------------------------------------------------}
procedure xuly;
var i,k:longint;
b:mang;
begin
for i:=1 to n do write(f,a[i],' ');
writeln(f);
k:=0;
for i:=1 to n do
if i mod 2<>0 then
begin
inc(k);
b[k]:=a[i]+a[i+1];
end;
for i:=1 to k do write(f,b[i],' ');
writeln(f);
for i:=1 to k do
if (b[i]>0) and (scp(b[i])) then write(f,b[i],' ');
end;

{--------------------------------------------------------}
begin
doc;
ghi;
xuly;
close(f);
end.

27 tháng 5 2017

tuy có chút ko hỉu cho lắm nhưng dù sao vẫn cảm ơn bạn nhìu! <3

uses crt;

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

i,n,x:integer;   

kt,kt1:boolean;

begin

clrscr;

repeat   

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

until (1<=n) and (n<=5);

for i:=1 to n do 

begin     

repeat       

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

until (-100<=a[i]) and (a[i]<=100); 

end;

kt:=true;

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

for i:=2 to n do 

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

begin       

kt:=false;       

break;     

end;

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

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

kt1:=true;

for i:=1 to n do 

if ((a[i]>0) and (a[i+1]>0)) or ((a[i]<0) and (a[i+1]<0)) then     

begin       

kt1:=false;       

break;     

end;

if kt1=true then writeln('Mang A co doi sanh voi nhau')

else writeln('Mang A khong doi sanh voi nhau');

readln;

end.

uses crt;

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

i,n,t,dem:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

t:=0;

dem:=0;

for i:=1 to n do 

  if a[i] mod 2=0 then

begin

t:=t+a[i];

inc(dem);

end;

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

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

readln;

end.

uses crt;

var x,i,n,t:integer;

begin

clrscr;

readln(n);

t:=0;

for i:=1 to n do

begin

readln(x);

if x<>0 then t:=t+x;

end;

write(t);

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long a[200],i,n,k;

int main()

{

cin>>n;

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

cin>>k;

kt=false;

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

if (a[i]==k)

{

cout<<i<<" ";

kt=true;

}

cout<<endl;

if (kt==false) cout<<"Khong co so k trong day"<<endl;

sort(a+1,a+n+1);

for (i=1; i<=n; i++) cout<<a[i]<<" ";

return 0;

}

uses crt;

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

n,i:integer;

s:real;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

s:=1;

for i:=1 to n do

s:=s*a[i];

writeln('Tich cac so trong day la: ',s:0:0);

readln;

end.

uses crt;

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

n,i,t:integer;

begin

clrscr;

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

for i:=1 to n do 

begin

write('H[',i,']='); readln(h[i]);

end;

t:=0;

for i:=1 to n do 

  if h[i] mod 2=0 then t:=t+h[i];

writeln('Tong cac so chia het cho 2 la: ',t);

readln;

end.