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..100] of integer;
i,n,S,d:byte;
begin
write(' n = '); readln(n);
for i:=1 to n do begin
write('A[',i,'] = ');
readln(A[i]);
end;
d:=0; S:=0;
for i:=1 to n do if A[i] mod 2 = 0 then begin
d:=d+1;
S:=S+A[i];
end;
write('Dãy có ',d,' phần tử là số chẵn và tổng của chúng là : S = ',S);
readln
end.
uses crt;
var a:array[1..1000]of integer;
i,n,dem,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=1000);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until abs(a[i])<=1000;
end;
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i]=0 then inc(dem);
writeln('So phan tu bang 0 la: ',dem);
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln('Tong cac phan tu chan la: ',t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,dem,t;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) t+=x;
if (x%3==0) dem++;
}
cout<<"Tong cac so chan la: "<<t<<endl;
cout<<"So luong phan tu chia het cho 3 la: "<<dem;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,dem:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
dem:=0;
for i:=1 to n do
if trunc(sqrt(a[i]))=sqrt(a[i]) then inc(dem);
writeln(dem);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[100],n,i,t,t1,dem,dem1;
//chuongtrinhcon
bool ktnt(long long x)
{
if (x<=1) return(false);
for (int i=2; i*i<=x; i++)
if (x%i==0) return(false);
return true;
}
//chuongtrinhchinh
int main()
{
cin>>n;
for (i=1; i<=n; i++)
{
cin>>a[i];
}
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++) if (a[i]%2==0) t=t+a[i];
cout<<t<<endl;
dem=0;
for (i=1; i<=n; i++) if (a[i]%3==0) dem++;
cout<<dem<<" ";
t1=0;
dem1=0;
for (i=1; i<=n; i++)
if (a[i]%2!=0)
{
t1+=a[i];
dem1++;
}
cout<<fixed<<setprecision(2)<<(t1*1.0)/(dem1*1.0)<<endl;
for (i=1; i<=n; i++)
if (ktnt(a[i])==true) cout<<a[i]<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,t,dem,x;
int main()
{
cin>>n;
t=0;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
t=t+x;
if (x%2==0) dem++;
}
cout<<t<<endl;
cout<<dem;
return 0;
}
Var i,k,n,bk,tong: integer;
a: array[1..1000] of integer;
Begin
write('Nhap K: '); readln(k);
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
{câu a}
For i:=1 to n do
if a[i]=k then bk:=bk+1;
writeln('Co so phan tu bang k la:',k);
{câu b}
For i:=1 to n do
if a[i]=k then
begin
write(i,' ');
tong:=tong+a[i];
end;
write('. Tong la:',tong);
readln
end.
uses crt;
var k,n,tong,d,i:longint;a:array[1..1000]of longint;
begin
clrscr;
write('n=');readln(n);
write('k=');readln(k);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
end;
d:=0;
for i:=1 to n do if(a[i]=k)then inc(d);
writeln('so phan tu bang voi:',k,' la:',d);
write('cac so co vi tri bang voi:',k,' la:');
tong:=0;
for i:=1 to n do if(a[i]=k)then
begin
write(i,' ');
tong:=tong+a[i];
end;
write('tong cua cac so bang voi:',k,' la:',tong);
readln;
end.
uses crt;
var a:array[1..10]of longint;
n,i,t,dem,dem1,dem2,t1: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;
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t);
t1:=0;
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i]>0 then dem1:=dem+1;
if a[i] mod 2=0 then
begin
dem2:=dem2+1;
t1:=t1+a[i];
end;
end;
writeln(dem1);
writeln(t1/dem2:4:2);
readln;
end.
uses crt;
var a:array[1..10]of longint;
n,i,t,dem,dem1,dem2,t1: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;
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t);
t1:=0;
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i]>0 then dem1:=dem+1;
if a[i] mod 2=0 then
begin
dem2:=dem2+1;
t1:=t1+a[i];
end;
end;
writeln(dem1);
writeln(t1/dem2:4:2);
readln;
end.