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;
const fo='data.txt';
var f1:text;
a:array[1..10]of integer;
i,n:integer;
begin
clrscr;
assign(f1,fo); rewrite(f1);
n:=10;
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(f1,a[i]:4);
close(f1);
readln;
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;
var a:array[1..100]of integer;
i,n,dem1,dem2:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
writeln;
dem1:=0;
for i:=1 to n do
if (a[i]>a[i-1]) and (a[i]>a[i+1]) then dem1:=dem1+1;
dem2:=0;
for i:=1 to n do
if (a[i]<a[i-1]) and (a[i]<a[i+1]) then dem2:=dem2+1;
writeln(dem1);
writeln(dem2);
readln;
end.
uses crt;
var a:array[1..200]of integer;
n,i,k,t,t1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
t:=0;
for i:=1 to n do
if a[i] mod 2<>0 then t:=t+a[i];
t1:=0;
for i:=1 to n do
if a[i] mod k=0 then t1:=t1+a[i];
writeln('Tong cac phan tu le la: ',t);
writeln('Tong cac phan tu la boi cua ',k,' la: ',t1);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],b[1000],i,n,t,dem;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
dem=0;
for (i=1; i<=n; i++)
if (a[i]%2!=0)
{
dem++;
b[dem]=a[i];
}
for (i=1; i<=dem; i++) cout<<b[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=dem; i++) t+=b[i];
cout<<t;
return 0;
}
uses crt;
var a:array[1..100]of integer;
n,i,k,dem,dem1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem);
if a[i] mod k=0 then inc(dem1);
end;
writeln('So phan tu chan la: ',dem);
writeln('So phan tu chia het cho ',k,' la: ',dem1);
readln;
end.
uses crt;
var a:array[1..20]of integer;
i,n,t,dem:integer;
begin
clrscr;
for i:=1 to 20 do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]>0;
end;
t:=0;
for i:=1 to 20 do
t:=t+a[i];
writeln('Tong cac so trong mang la: ',t);
dem:=0;
for i:=1 to 20 do
if a[i] mod 2=0 then inc(dem);
writeln('Trong mang co ',dem,' so chan');
readln;
end.
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.
tuy có chút ko hỉu cho lắm nhưng dù sao vẫn cảm ơn bạn nhìu! <3