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.
Var a:array[1..1000] of integer;
i,n,d:integer;
sd,s:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
s:=s+a[i];
End;
For i:=1 to n do
If a[i] > 0 then
Begin
d:=d+1;
sd:=sd+a[i];
End;
Writeln('Tong cac so vua nhap la ',s);
Write('Co ',d,' so nguyen duong va tong cua chung la ',sd);
Readln
End.
Câu 1:
uses crt;
var a:array[1..100]of real;
i,n:integer;
t:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln(t:4:2);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
t:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=1;
for i:=1 to n do
t:=t*a[i];
writeln(t:4:2);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i]>0 then t:=t+a[i];
writeln(t);
readln;
end.
Câu 1:
uses crt;
var a:array[1..200]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln(t);
readln;
end.
Câu 4:
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if (10<a[i]) and (a[i]<20) then
begin
inc(dem);
t:=t+a[i];
end;
writeln('So phan tu lon hon 10 va nho hon 20 la: ',dem);
writeln('Tong cac phan tu lon hon 10 va nho hon 20 la: ',t);
readln;
end.
Câu 5:
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
inc(dem);
t:=t+a[i];
end;
writeln('So so chan la: ',dem);
writeln('Tong cac so chan la: ',t);
readln;
end.
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
readln;
end.
Bài 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,dem=0,s=0;
cin >> n;
for (long long i=1;i<=n;i+=2){
dem++;
s+=i;
}
cout << "tu 0 den n co: " << dem << " so le" << endl;
cout << "tong cac so le do la: " << s;
return 0;
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,dem=0,s=0;
cin >> n;
for (long long i=1;i<=n;i+=2){
dem++;
s+=i;
}
cout << "tu 0 den n co: " << dem << " so le" << endl;
cout << "tong cac so le do la: " << s;
return 0;
}
var i,n,d:integer;
s:longint;
begin
write('n = ');readln(n);
for i:=1 to n do
if i mod 2 <> 0 then
begin
d:=d+1;
s:=s+i;
end;
writeln('co ',d,' so le');
write('tong cac so le la ',s);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,t,dem;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
t=0;
dem=0;
for (i=1; i<=n; i++)
if (a[i]>0)
{
t+=a[i];
dem++;
}
cout<<t<<endl;
cout<<dem;
return 0;
}