Nhập các số 5; 7; 9 vào các ô A1; A2; A3. Hàm nào sau đây tính tổng của 100 và trung bình các số trên?
A. =SUM(100,(A1:A3)) B. =SUM(100,SUM(A1:A3))
C. =SUM(100,AVERAGE(A1:A3)) D. =AVERAGE(100,AVERAGE(A1:A3)
viết chương trình pascal nhập n số nguyên (5<=n<100) hiện dãy số vừa nhập . tính tổng các số >10
Program HOC24;
var i,n: byte;
t: longint;
a: array[1..100] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i]>10 then t:=t+a[i];
writeln('Tong cac so lon hon 10 la: ',t);
readln
end.
VCT nhập vào 1 mảng số. Hãy:
a)Tính tổng các số chia hết cho 3 và 6
b)In ra các số lớn hơn 3
c) In mảng đã nhập vào
d) Đếm xem có bao nhiêu chứ số lẻ nhập vào chia hết cho 5. In đếm
uses crt;
var a:array[1..100]of integer;
i,n,t,dem: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 6=0 then t:=t+a[i];
writeln('Tong cac so chia het cho 3 va 6 la: ',t);
for i:=1 to n do
if a[i]>3 then write(a[i]:4);
writeln;
for i:=1 to n do
write(a[i]:4);
dem:=0;
for i:=1 to n do
if (a[i] mod 2<>0) and (a[i] mod 5=0) then inc(dem);
writeln(dem);
readln;
end.
Bài 1:Nhập 1mảng có n số nguyên từ bàn phím
1.In mảng vừa nhập
2.Đếm và in ra các số chẵn 3.Tính tổng các số lẻ
4.Đếm và in ra các số lẻ không chẵn
Bài 2:Nhập 1 mảng gồm n số nguyên từ bàn phím.In mảng vừa nhập các phần tử cách nhau 5 khoảng trống.Tìm max,min của mảng
Bài 3:Nhập 1 mảng gồm n số thực từ bàn phím.In mảng vừa nhập,mỗi mảng cách nhau 4 vị trí.In ra màn hình tất cả các số âm in trong mảng.Tính tổng các số âm đó
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,ln,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
ln=a[1];
nn=a[1];
for (i=2; i<=n; i++)
{
ln=max(ln,a[i]);
nn=min(nn,a[i]);
}
cout<<ln<<" "<<nn;
}
Viết chương trình tính tổng các số chẵn và các số lẻ từ 1 đến N.Với N nhập từ bàn phím.
Ví dụ: Nhập N=5 thì kết quả: Tổng các số từ 1 đến N là 6,Tổng các số lẻ là 9
{PROGRAM Bai_tap1;
USES crt;
VAR n, i, C, L:Bytbe;
BEGIN
clrscr;
Write('Nhap n:');Readln(n);
C:=0;L:=0;
For i:=1 to n do
If i mod 2=0 then C:=C+i else L:=L+i;
writeln('Tong cac so chan la:',C);
writeln ('Tong cac so le la:',L);
Readln;
end.
}
Viết chương trình nhập vào một dãy số tính tổng các số không chia hết cho 5 có trong dãy vừa nhập
program tinhTong;
var
n,i,s: integer;
a: array[1..100] of integer;
begin
write('Nhap so luong phan tu: ');
readln(n);
for i := 1 to n do
begin
write('a[',i,'] = ');
readln(a[i]);
end;
s := 0;
for i := 1 to n do
begin
if (a[i] mod 5 <> 0) then
s := s + a[i];
end;
writeln('Tong cac so khong chia het cho 5: ', s);
readln;
end.
program TinhTong;
var
n, i, s, x: integer;
begin
write('Nhap so luong phan tu cua day: ');
readln(n);
s := 0;
for i := 1 to n do
begin
write('Nhap phan tu thu ', i, ': ');
readln(x);
if (x mod 5 <> 0) then
s := s + x;
end;
writeln('Tong cac so khong chia het cho 5 la: ', s);
end.
Viết chương trình nhập vào một dãy số a có n phần tử nhập vào từ bàn phím in ra màn hình các phần tử lớn hơn 5 của dãy số vừa nhập vào?
Program HOC24;
var 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;
for i:=1 to n do if a[i]>5 then write(a[i],' ');
readln
end.
viết chương trình nhập vào số tự nhiên N(N<=100)sau đó tính tổng các số lẻ từ 1 đến N.Ví dụ nhập N=5.Tổng các số lẻ=9.Giúp tớ đi huhu ngày mai thi r TT
uses crt;
var i,n,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do if i mod 2=1 then t:=t+i;
writeln(t);
readln;
end.
1.Nhập một mảng gồm n số nguyên từ bàn phím 2.In mảng vừa nhập ra màn hình theo chiều ngang các phần tử cách nhau 5 vị trí 3.Đếm và in ra các số lử âm ra dòng tiếp theo 4.Tính tổng các số chẵn 5.Sắp xếp theo chiều giảm dần Mn giúp e vs ạ!!!!
#include <bits/stdc++.h>
using namespace std;
long long a[10000],i,n;
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++) if (a[i]%2==0) t+=a[i];
cout<<"Tong cac so chan la: "<<t<<endl;
sort(a+1,a+n+1);
cout<<"Day so giam dan la: ";
for (i=n; i>=1; i--) cout<<a[i]<<" ";
return 0;
}
viết chương trình nhập 5 số nguyên bất kì, tính tổng các số âm
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d,e;
cin >> a >> b >> c >> d >> e;
long t=0;
if (a<0) t=t+a;
if (b<0) t=t+b;
if (c<0) t=t+c;
if (d<0) t=t+d;
if (e<0) t=t+e;
cout << t;
return 0;
}
Viết chương trình nhập vào số nguyên n và tính tổng các số lẻ (các số lẻ là số không chia hết cho 2) trong khoảng từ 1 đến n ( ví dụ nhập = 10, ta sẽ có tổng sau s=1+3+5+7+9=25)
Viết chương trình nhập vào số nguyên n và tính tổng các số lẻ (các số lẻ là số không chia hết cho 2) trong khoảng từ 1 đến n ( ví dụ nhập = 10, ta sẽ có tổng sau s=1+3+5+7+9=25)
uses crt;
var i,n,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
for i:=1 to n do
if i mod 2=1 then s:=s+i;
writeln(s);
readln;
end.