Viết phương trình nhập vào 1 dãy số rồi sau đó xuất ra màn hình số nhỏ nhất của dãy vừa nhập ( làm theo kiểu mảng 1 chiều )
Viết chương trình nhập biến mảng M gồm 100 phần tử thuộc kiểu số nguyên +nhập các phần tử và in ra màn hình + tìm và in ra màn hình giá trị lớn nhất trong dãy số vừa nhập +tìm và in ra màn hình giá trị nhỏ nhất trong dãy số vừa nhập
uses crt;
var a: array[1..100] of longint;
i,n,max,min: longint;
begin
clrscr;
readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': ');
readln(a[i]);
end;
max:=a[1]; min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('So lon nhat trong mang la: ',max);
write('So nho nhat trong mang la: ',min);
readln
end.
Câu 1. Viết chương trình thực hiện yêu cầu sau: a, Sử dụng mảng để nhập từ bàn phím các phân tử của 1 dãy số có kiểu số nguyên? Biết độ dài của dãy số được nhập từ bàn phím . b, In ra màn hình các số vừa nhập của dãy số đó. c, In ra màn hình số lớn nhất trong dãy số. Mn giúp mik với mik cần gấp.mik c.ơn
Var a:array:[1..1000] of integer;
i,n,max:integer;
Begin
Write('Nhap so luong phan tu n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
End;
Write('Cac diem vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
max:=a[1];
For i:=2 to n do
if a[i] > max then max:=a[i];
write('So lon nhat la ',max);
Readln
End.
Viết chương trình nhập mảng n số nguyên. Hoán đổi phần tử lớn nhất và nhỏ nhất của dãy vừa nhập. In dãy sau khi hoán đổi ra màn hình
Bài 1: Viết chương trình nhập vào 1 dãy số nguyên xuất dãy số đó ra màn hình tính tích các số chẵn và xuất ra màn hình.
Bài 2: Viết chương trình nhập 1 dãy số nguyên, xuất dãy số đó ra màn hình tính tổng các số chẵn các số lẻ và xuất ra màn hình.
program timtich;
uses crt;
var i,n:integer;
tich:longint;
a:array[1..100]of integer;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
tich:=1;
writeln;
for i:=1 to n do
if a[i] mod 2=0 then tich:=tich*a[i];
writeln('tich ca phan tu chan cua mang la:',tich);
readln;
end.
program timtong;
uses crt;
var i,n:integer;
tong:longint;
a:array[1..100]of integer;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
tong:=0;
writeln;
for i:=1 to n do
if a[i] mod 2=0 then tong:=tong+a[i];
writeln('tong cac phan tu chan cua mang la:',tong);
tong:=0;
writeln;
for i:=1 to n do
if a[i] mod 2=1 then tong:=tong+a[i];
writeln('tong cac phan tu le cua mang la:',tong);
readln;
end.
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
s:=1;
for i:=1 to n do
if a[i] mod 2=0 then s:=s*a[i];
writeln(s);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t1,t2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t1:=0;
t2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then t1:=t1+a[i]
else t2:=t2+a[i];
end;
writeln('Tong cac so chan la: ',t1);
writeln('Tong cac so le la: ',t2);
readln;
end.
Viết chương trình sử dụng biến mảng để nhập từ bàn phím các phần tử của một dãy số nguyên in ra màn hình phần tử nhỏ nhất trong dãy số nguyên vừa nhập
var a:array[1..1000] of integer;
i,n,min:integer;
begin
write('n = ');readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
end;
min:=a[1];
for i:=2 to n do
if min > a[i] then min:=a[i];
write('So nho nhat la ',min);
readln
end.
Mong mọi người giúp em ạ. Em cảm ơn 1/viết phương trình nhập vào một xâu xuất xâu vừa nhập sang chữ hoa 2/ viết phương trình nhập vào mảng 1 chiều gồm một dãy số nguyên. đếm xem có hai nhiều số dương trong dãy vừa nhập
Viết chương trình nhập vào
dãy số nguyên gồm có N phần tử.
- Xuất ra màn hình dãy số vừa nhập.
- Xuất ra màn hình dãy số vừa nhập
theo chiều ngược lại.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
1.Viết chương trình nhập vào một dãy số gồm n phần tử.Sắp xếp dãy số theo thứ tự tăng dần sau đó in ra màn hình dãy số đã sắp xếp. 2.Viết chương trình nhập vào một dãy số gồm n phần tử. Sắp xếp dãy số theo thứ tự giảm dần sau đó in ra màn hình dãy số đã sắp xếp.(cứu mk với mai thi r ạ🥲
1)
Var array:[1..1000] of integer;
i,n,t:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do
If a[i] > a[i+1] then
Begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
End;
Write('Sap xep tang dan ');
For i:=1 to n do write(a[i]:8);
Readln
End.
2)
Var array:[1..1000] of integer;
i,n,t:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do
If a[i] < a[i+1] then
Begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
End;
Write('Sap xep giam dan ');
For i:=1 to n do write(a[i]:8);
Readln
End.
sử dụng biến mảng viết chương trình nhập vào N số nguyên từ bàn phím .sau đó in ra màn hình giá trị lớn nhất và nhỏ nhất của dãy số
giúp mik với
Program HOC24;
var min,max,i,n: integer;
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;
max:=a[1]; min:=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];
end;
writeln('Gia tri lon nhat la: ',max);
write('Gia tri nho nhat la: ',min);
readln
end.