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.
Program ct;
Var i,n,so le, so chan:integer;
B:Array[1..n] of integer;
Begin
Write('n=');Readln(n);
For i:=1 to n do begin Write('B[',i,']=');
Readln(B[i]);
End;
For i:=1 to n do Begin
if B[i] mod 2 <>0 then writeln('so le , ' );
If B[i] mod 2=0 then writeln('so chan ,' );
End;
Readln
End.
Lời giải:
Bài 1 :
a) var A : array[1..100] of real ;
b) var B : array[1..20] of integer ;
c) A[7] := 8 ;
Bài 2 :
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n: integer ;
begin
write('nhap do dai cua mang'); readln(n);
write('Nhap cac gia tri cua phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
readln
end.
Bài 3 :
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n: integer ;
begin
write('Co tat ca so ban hoc sinh la'); readln(n);
write('Nhap diem mon tin cua cac ban');
for i:= 1 to n do
begin
write('Ban thu ',i,':'); readln(a[i]);
end;
readln
end.
Bài 4 : a,b giống bài 3
c)
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n,tong : integer ;
begin
write('nhap do dai cua mang'); readln(n);
write('Nhap cac gia tri cua phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
tong:=0;
for i:= 1 to n do
if a[i] > 0 then tong:=tong+1;
write('Ket qua la',tong);
readln
end.
Bài 5: a và b tương tự bài 3
c+d )
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n: integer ;
begin
write('nhap do dai cua mang'); readln(n);
write('Nhap cac gia tri cua phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
for i:= 1 to n do
c) if i mod 2= 0 then write('Cac so chan cua mang la:',i);
d) if i mod 2= 1 then write('Cac so le cua mang la:',i);
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.
Program HOC24;
var a: array[1..50] of integer;
i,n: byte;
t: longint;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Cac phan tu chan trong mang la: ');
for i:=1 to n do
if a[i] mod 2=0 then
begin
write(a[i],' ');
t:=t+a[i];
end;
writeln;
write('Tong cac phan tu chan trong day la: ',t);
readln
end.
Program HOC24;
var i,n: byte;
t: longint:
a: array[1..50] of integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do begin write('A[',i,']='); readln(a[i]); end;
t:=0;
write('Cac phan tu chan co trong mang la: ');
for i:=1 to n do
if a[i] mod 2=0 then
begin
write(a[i],' ');
t:=t+a[i];
end;
writeln;
write('Tong cac phan tu chan do la: ',t);
readln
end.
Làm như z có đg ko
Uses crt;
Var n,i: integer;
A: Array[1..1000] of integer;
Begin
clrscr;
Repeat
Write('Nhap n: '); Readln(n);
Until (n<103) and (n>0);
a)
For i:=1 to n do
begin
Write('Nhap phan tu A[',i,']= ');
Readln(A[i]);
end;
b)
Write('Cac phan tu chan co trong mang: ');
For i:=1 to n do
If A[i] mod 2=0 then write(A[i],' ');
writeln;
c)
Write('Cac phan tu le co trong mang: ');
For i:=1 to n do
If A[i] mod 2=1 then write(A[i],' ');
Readln
End.
Uses crt;
var i,n: longint;
a: array[1..103] of longint;
begin clrscr;
readln(n);
for i:=1 to n do read(a[i]); readln;
for i:=1 to n do if(a[i] mod 2=0) then write(a[i],' ');
for i:=1 to n do if(a[i] mod 2<>0) then write(a[i],' ');
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.
Program HOC24;
var i,n: integer;
t: longint;
a: array[1..1000] of integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=a[1]+a[n];
write('Ket qua la: ',t);
readln
end.
program TinhTongPhanTuDauVaPhanTuCuoi;
var
A: array[1..1000] of integer;
n, TongDau, TongCuoi: integer;
i: integer;
begin
write('Nhap so phan tu cua mang: ');
readln(n);
for i := 1 to n do
begin
write('A[', i, '] = ');
readln(A[i]);
end;
TongDau := A[1];
TongCuoi := A[n];
writeln('Cac phan tu trong mang la: ');
for i := 1 to n do
begin
write(A[i], ' ');
if i = 1 then
continue;
if i = n then
break;
TongDau := TongDau + A[i];
end;
writeln();
writeln('Tong phan tu dau va phan tu cuoi cua mang la: ', TongDau + TongCuoi);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,t;
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++) t+=a[i];
cout<<t;
return 0;
}
program TinhTongMang;
var
a: array[1..10] of integer;
i, tong: integer;
begin
tong := 0;
writeln('Nhap mang a gom 10 phan tu:');
for i := 1 to 10 do
begin
write('a[', i, '] = ');
readln(a[i]);
tong := tong + a[i];
end;
writeln('Tong cac phan tu cua mang la: ', tong);
end.