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 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.
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.
program tim_so_nguyen_am;
uses crt;
var n,i:integer;
b:array[1..1000]of integer;
begin
clrscr;
write('nhap so phan tu :');readln(n);
repeat
for i:=1 to n do
begin
write('nhap phan tu b[',i,']:');readln(b[i]);
end;
if abs(a[i]>1000)then write('ban hay nhap lai:');
until abs(b[i]<=1000);
writeln('cac phan tu nguyen duong cua mang la:');
for i:=1 to n do
if b[i]>=0 then write(b[i]:5);
writeln;
writeln('cac phan tu nguyen am cua mang la:');
readln;
end.
for i:=1 to n do
if b[i]<0 then write(b[i]:5);
uses crt;
var b:array[1..25]of integer;
i,n,dem1,dem2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('B[',i,']='); readln(b[i]);
end;
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if b[i]>0 then inc(dem1);
if b[i]<0 then inc(dem2);
end;
writeln('So cac so nguyen duong la: ',dem1);
writeln('So cac so nguyen am la: ',dem2);
readln;
end.
Câu 1:
var a:array[1..100]of integer;
Câu 2:
uses crt;
var a:array[1..10]of integer;
i:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to 10 do
write(a[i]:4);
readln;
end.
Câu 3:
uses crt;
var a:array[1..15]of integer;
i,n,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=15);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]<=100;
end;
writeln('Mang da nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln('Tong cac phan tu chia het cho 3 la: ',t);
writeln('Cac so chan o vi tri le trong day la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (i mod 2=1) then write(a[i]:4);
readln;
end.
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.
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x<0) t+=x;
}
cout<<t;
return 0;
}