1) Nhap va xuat ra man hinh gia tri tong cua cac phan tu trong mang
viet phuong trinh nhap vao mang a gom N(N<=100) cac so nguyen roi thuc hien cac yeu cau
1. in ra danh sach cac so chia het cho 4
2. in ra mang hinh gia tri lon nhat chia het cho 7 va chi so do
3. xuat ra mang hinh cac phan tu cua mang do theo thu tu giam dan
uses crt;
var a,b:array[1..100]of integer;
n,i,dem,max,tam,j:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=100);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so chia het cho 4 la: ');
for i:=1 to n do
if a[i] mod 4=0 then write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i] mod 7=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
max:=b[1];
for i:=1 to dem do
if max<b[i] then max:=b[i];
writeln('So lon nhat chia het cho 7 la: ',max);
writeln('Cac chi so cua no trong day A la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
writeln;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('Day so sau khi sap xep giam dan la: ');
for i:=1 to n do
write(a[i]:4);
readln;
end.
Giúp mình với ạ !
viet chuong trinh nhap mang a bat ky tu ban phim( n nho hon hoac bang 100) tinh va xuat ra mang hinh cac phan tu le hoac chan cua may vua nhap
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('n='); readln(n);
if (n>0) and (n<=100) then
begin
t:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
if (a[i] mod 2=0) or (a[i] mod 2=1) then t:=t+a[i];
end;
writeln('tong cac phan tu chan hoac le trong day la: ',t);
end
else writeln('vui long nhap lai');
readln;
end.
viet chuong trinh nhap vao mang 1 chieu ( n nho hon hoac bang 250), in ra tat ca cac phan tu va tinh tong cac phan tu cua mang
uses crt;
var a:array[1..250]of integer;
i,n,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
writeln;
for i:=1 to n do t:=t+a[i];
writeln(t);
readln;
end.
Viet chuong trinh nhap vao 1 mang be hon 20 phan tu
a/ sap xep mang theo thu tu lon dAN
b/ gia tri trung binh cua cac phan tu
c/ in ra phan tu lon nhat va phan tu nho nhat
D/ IN Ra cac phan tu la so chan
uses crt;
var j,tg,s,max,min,i,n:longint;
a:array[1..19] of longint;
s1:real;
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-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
for i:=1 to n do
write(a[i],' ');writeln;
for i:=1 to n do
s:=s+a[i];
s1:=s/n;
writeln(‘Gia tri trung binh cua cac phan tu la: ‘,s1:0:0);
min:=a[1];max:=a[1];
for i:=2 to n do begin
if a[i]>max then max:=a[i];
if a[i]<min then min:=a[i];
write('Phan tu lon nhat la: ',max,' ','Phan tu nho nhat la: ',min); writeln;
for i:=1 to n do
if (a[i]<>0) and (a[i] mod 2=0) then write(a[i],' ');
readln
end.
viet chuong trinh nhap vao cac so nguyen tu ban phim va tinh tong cua chung.Chuong trinh dung lai khi tong lon hon hoac bang a(a la so nhap tu ban phim)va thong bao tong do ra man hinh(Free Pascal)
Giup minh voi
1) Trong tong gia tri xuat, nhap khau cua the gioi, nhom cac nuoc phat trien chiem
A. 50% B. 55%
C. gan 60% D. hon 60%
viet chuong trinh nhap vao tu ban phim so nguyen duong N , tinh tong gia tri chia het cho 3 trong pham vi tu 1 den N , sau do in ra man hinh
uses crt;
var n,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 3=0 then t:=t+i;
writeln(t);
readln;
end.
viet chuong trinh nhap vao mang so nguyen a(toi da 100 phan tu) tu ban phim in len man hinh cac phan tu chia het cho K (khong duoc nhap vao tu ban phim khi chay chuong trinh) trong mang
1) Viet chuong trinh nhap 2 so thuc tu ban phim. Doi gia tri 2 so do va in ket qua ra man hinh
#include <bits/stdc++.h>
using namespace std;
double a,b;
int main()
{
cin>>a>>b;
cout<<"a truoc khi doi la:"<<fixed<<setprecision(2)<<a<<endl;
cout<<"b truoc khi doi la:"<<fixed<<setprecision(2)<<b<<endl;
swap(a,b);
cout<<"a sau khi doi la:"<<fixed<<setprecision(2)<<a<<endl;
cout<<"b sau khi doi la:"<<fixed<<setprecision(2)<<b;
return 0;
}