Viết chương trình Pascal thực hiện yêu cầu sau:
a)Sử dụng biến mạng , nhập vào dãy số nguyên từ bàn phím ,in ra màn hình dãy số đó
b)In ra màn hình tổng của dãy số đó
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.
sử dụng biến mảng viết chương trình nhập vào 1 dãy số gồm n số nguyên từ bàn phím . In ra màn hình tổng các số dương trong dãy số đó
Var a:array[1..1000] of integer;
s:longint;
i,n:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i);readln(a[i]);
If a[i] > 0 then s:=s+a[i];
End;
Write('Tong la ',s);
Readln
End.
Viết chương trình pascal 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 và in ra màn hình số lớn nhất của dãy số vừa nhập từ bàn phím.
sử dụng biến mảng Viết chương trình nhập vào dãy số gồm n số nguyên từ bàn phím in ra màn hình tổng các số dương trong dãy số đó Giúp mình với
uses crt;
var a:array[1..100]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]>0 then t:=t+a[i];
writeln(t);
readln;
end.
sử dụng biến mảng Viết chương trình nhập vào một dãy số gồm n số nguyên từ bàn phím in ra màn hình giá trị lớn nhất của dãy số đó
uses crt;
var a:array[1..100]of integer;
i,n,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln(max);
readln;
end.
Sử dụng biến mảng viết chương trình nhập vào một dãy số gồm N số nguyên tử bàn phím in ra màn hình tổng các số dương trong dãy số đó.
uses crt;
var a:array[1..100]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]>0 then t:=t+a[i];
writeln(t);
readln;
end.
viết chương trình sử dụng biến mảng để nhập một dãy số gồm N số nguyên từ bàn phím và thực hiện: +tính tổng các số trong dãy đó. +in ra màn hình các số lớn hơn 50 trong dãy số đó. +tìm số nhỏ nhất trong dãy đó Cần gấp ạ
var a:array[1..1000] of integer;
i,n,min:integer;
s:longint;
begin
write('n = ');readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
s:=s+a[i];
end;
writeln('Tong la ',s);
min:=a[1];
for i:=2 to n do
if a[i] < min then min:=a[i];
write('Cac so chan la ');
for i:=1 to n do
if a[i] mod 2 = 0 then write(a[i]:8);
writeln;
write('so nho nhat la ',min);
readln
end.
viết 1 chương trình thực hiện các yêu cầu sau:
a/Nhập vào dãy số n số tự nhiên bất kì nhỏ hơn 100 từ bàn phím.
b/Tính tích các phần tử của dãy số.
c/Tính tổng các phần tử của dãy số.
d/In ra màn hình số lớn nhất trong các dãy số ở trên.
e/In ra màn hình số lớn nhất trong các dãy số ở trên.
CẦN GẤP Ạ! CẢM ƠN MN!
#include <bits/stdc++.h>
using namespace std;
long long a[100],n,i,s,t,ln,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
s=1;
t=0;
ln=a[1];
nn=a[1];
for (i=1; i<=n; i++)
{
s=s*a[i];
t+=a[i];
ln=max(ln,a[i]);
nn=min(nn,a[i]);
}
cout<<s<<endl;
cout<<t<<endl;
cout<<ln<<endl;
cout<<nn;
return 0;
}
Cho dãy N số nguyên ( với n nhập vào từ bàn phím) . Viết chương trình thực hiện các yêu cầu sau. a. Nhập vào dãy số n và giá trị từng phần của dãy. b. Xuất giá trị của dãy vừa nhập. c. Tính tổng các phần tử của dãy. d. In ra màn hình giá trị Max, Min của dãy. e. Tính tổng các phần tử dương của dãy. f. Tính tổng các phần tử âm của dãy. g. Tính tổng các phần tử chẵn của dãy. h. Tính tổng các phần tử lẻ của dãy. i. Sắp xếp các phần của dãy theo thứ tự giảm dần. k. Sắp xếp các phần của dãy theo thứ tự tăng dần.