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.
Bài 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 5=0 then t:=t+a[i];
writeln('Tong cac so chia het cho 5 la: ',t);
readln;
end.
Bài 2:
uses crt;
var st:string;
d,i:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
writeln(st);
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.
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.
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if ((x<0) and (x%2!=0)) t=t+x;
}
cout<<t;
return 0;
}
cau 1:
uses crt;
var a:array[1..100] of integer;
n,i,min: integer;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
min:=a[1];
for i:=2 to n do
if min>a[i] then min=a[i];
writeln(a[i]);
readln;
end.
cau 2:
uses crt;
g:text;
s:string;
const fo='CHUSO.TXT';
begin
assign(g,fo);
rewrite(g);
readln(s);
for i:=1 to length(s) do
if not((s[i] in ['a'..'z'])and(s[i] in ['A'..'Z])) then delete(s,i,1);
writeln(g,s);
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;
}
# Nhap mang
arr = [ ]
for i in range(10):
arr.append(int(input('Nhap phan tu: ')))
# Tinh va xuat ra tong cac phan tu le trong mang tong_cac_phan_tu_le = 0
for x in arr:
if x % 2 != 0:
tong_cac_phan_tu_le += x
print('Tong cac phan tu le trong mang la:', tong_cac_phan_tu_le)
# Nen va xuat ra ngoai man hinh so phan tu duong trong mang so_phan_tu_duong = 0
for x in arr:
if x > 0:
so_phan_tu_duong += 1
print('So phan tu duong trong mang la:', so_phan_tu_duong)
# Tinh va xuat ra man hinh trung binh cong cac phan tu trong mang tong_phan_tu = 0
for x in arr:
tong_phan_tu += x
trung_binh_cong = tong_phan_tu / len(arr)
print('Trung binh cong cac phan tu trong mang la:',trung_binh_cong)
# Tim va xuat ra man hinh gia tri va vi tri cua cac phan tu nho nhat trong mang
min_phan_tu = arr[0]
vi_tri_min_phan_tu = 0
for i in range(1, len(arr)):
if min_phan_tu > arr[i]:
min_phan_tu = arr[i]
vi_tri_min_phan_tu = i
print('Gia tri cua phan tu nho nhat trong mang la:', min_phan_tu)
print('Vi tri cua phan tu nho nhat trong mang la:', vi_tri_min_phan_tu)
tham khảo
Program Hotboy;
Uses crt;
Var A:array[1..100] of integer;
I,n : byte;
S:real;
Begin
Clrscr ;
S:=1;
Write('nhao so phan tu trong day'); 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 5 =0 then
S:=S* A[i] ;
Writeln('Tong cac phan tu chia het cho 5 trong mang la',S);
Readln
End.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
readln(n);
t:=1;
for i:=1 to n do
if a[i] mod 2<>0 then t:=t*a[i];
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t,dem;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0 && x>10) t+=x;
if (x%2!=0 || x<100) dem++;
}
cout<<t<<" "<<dem;
return 0;
}
1:
uses crt;
var st:string;
i,d,dem:integer;
begin
clrscr;
write('nhap xau:'); readln(st);
d:=length(st);
dem:=0;
for i:=1 to d do
if st[i]='a' then inc(dem);
writeln('so cac ki tu a trong xau la: ',dem);
readln;
end.
2:
uses crt;
var b:array[1..250]of integer;
m,i:integer;
begin
clrscr;
write('m='); readln(m);
for i:=1 to m do
begin
write('b[',i,']='); readln(b[i]);
end;
{---------------------xu-ly---------------------}
writeln('cac so le la: ');
for i:=1 to m do
if b[i] mod 2=1 then write(b[i]:4);
readln;
end.