viết chương trình nhập vào 1 dãy n số nguyên dương in ra màn hình các phần tử ở vị trí chẵn mà chia hết cho 5 và 7 bằng Dev-c++
Viết chương trình nhập một dãy gồm N số nguyên A1, A2, ...,AN. Tinh và đưa ra màn hình số lượng các phần tử ở vị trí lẻ chia hết cho 9 có trong dãy
Câu 2: (2.0 điểm) Viết chương trình nhập một số nguyên N từ bàn phím. Tinh và đưa ra màn hình tổng các số chẵn trong đoạn từ 1 đến N.
Câu 3: (1.0 điểm) Viết chương trình nhập một dãy gồm N số nguyên dương B1, B2, ..., BN. Nhập số nguyên X. Đưa ra màn hình vị trí các phần tử chia hết cho X và lớn hơn phần tử nhỏ nhất có trong dãy.
giúp em với ạ
Viết chương trình nhập từ bàn phím dãy số nguyên B gồm N phần tử b1, b2, …, bN (1 £ N £ 100) 1- Tính tổng các số chẵn chia hết cho 5 2- Đếm các số lẻ ở vị trí chẵn 3- Đưa ra mà hình danh sách các số lẻ chia hết cho 3
Viết chương trình nhập từ bàn phím dãy số nguyên B gồm N phần tử b1, b2, …, bN (1 £ N £ 100) 1- Tính tổng các số chẵn chia hết cho 5 2- Đếm các số lẻ ở vị trí chẵn 3- Đưa ra mà hình danh sách các số lẻ chia hết cho 3
#include <bits/stdc++.h>
using namespace std;
int B[100],n,t;
{
cin>>n;
for (int i=1; i<=n; i++) cin>>B[i];
t=0;
for (int i=1; i<=n; i++)
if (B[i]%10==0) t+=B[i];
cout<<t<<endl;
int dem=0;
for (int i=1; i<=n; i++)
if ((i%2==0) && (A[i]%2!=0)) dem++;
cout<<dem<<endl;
for (int i=1; i<=n; i++)
if ((A[i]%2!=0) && (A[i]%3==0)) cout<<A[i];
}
Viết chương trình nhập 1 mảng số nguyên dương gồm n phần tử
a, in ra màn hình mảng vừa nhập.
b, tìm kiếm các cặp 2 phần tử liên tiếp có tổng chia hết cho 10. in ra màn hình các cặp số và vị trí của nó
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
readln(n);
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
if (a[i]+a[i+1] mod 10=0) then
begin
writeln(a[i],' ',a[i+1]);
writeln(i,' ',i+1);
end;
readln;
end.
Viết chương trình nhập từ bàn phím dãy số nguyên A gồm N phần tử a1, a2, …, aN (1 £ N £ 100) 1- Tính tổng các số lẻ chia hết cho 3 2- Đếm các số chẵn ở vị trí lẻ 3- Đưa ra mà hình danh sách các số chẵn chia hết cho 5 Giúp tui zoiiii
program BaiToanMang;
var
A: array[1..100] of integer;
N, i, demChan, tongLeChia3: integer;
begin
write('Nhap so phan tu cua mang: ');
readln(N);
writeln('Nhap cac phan tu cua mang: ');
for i := 1 to N do
begin
write('a[', i, ']= ');
readln(A[i]);
end;
tongLeChia3 := 0;
for i := 1 to N do
begin
if (A[i] mod 2 = 1) and (A[i] mod 3 = 0) then
begin
tongLeChia3 := tongLeChia3 + A[i];
end;
end;
writeln('Tong cac so le chia het cho 3: ', tongLeChia3);
demChan := 0;
for i := 2 to N do
begin
if (A[i] mod 2 = 0) and (i mod 2 = 1) then
begin
demChan := demChan + 1;
end;
end;
writeln('So phan tu chan o vi tri le: ', demChan);
writeln('Cac so chan chia het cho 5: ');
for i := 1 to N do
begin
if (A[i] mod 2 = 0) and (A[i] mod 5 = 0) then
begin
write(A[i], ' ');
end;
end;
end.
ko bt đúng ko ko dùng pascal nhiều
Viết chương trình nhập từ bàn phím dãy số nguyên B gồm N phần tử b1, b2, …, bN (1 £ N £ 100) 1- Tính tổng các số chẵn chia hết cho 5 2- Đếm các số lẻ ở vị trí chẵn 3- Đưa ra mà hình danh sách các số lẻ chia hết cho 3 Help tui mng oi
viết chương trình nhập vào dãy số gồm N phần tử từ bàn phím
a) in ra màn hình vị trí của các số lẻ có trong dãy để nhập
b) in ra màn hình giá trị nhỏ nhất của dãy và vị trí của nó trong dãy
viết bằng chương trình C++
mảng(array) trong C++
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) if (a[i]%2!=0) cout<<i<<" ";
cout<<endl;
nn=a[1];
for (i=1; i<=n; i++) nn=min(nn,a[i]);
cout<<nn<<endl;
for (i=1; i<=n; i++) if (nn==a[i]) cout<<i<<" ";
return 0;
}
Viết một chương trình nhập n nguyên dương và n số nguyên a1, a2,…,an. a/ Tính tổng các số chẵn của dãy (In kết quả trên một dòng) b/ In các số của dãy nằm ở vị trí chẵn (2,4, 6…) ra màn hình (trên 1 dòng ),
Đề 1 Câu 1 (3.0 điểm): Viết chương trình nhập vào số nguyên dương N và thực hiện tính tổng S=3+5+7+..+(2n+1). Câu 2 (7.0 điểm): a. Viết chương trình nhập vào một dãy số nguyên có n phần tử. b. Đưa ra màn hình các phần tử có giá trị âm ở trong dãy. c. Tìm phần tử lớn nhất có trong dãy
Câu 1:
var i,n:integer;
s:longint;
begin
Write('n = ');readln(n)
for i:=1 to n do
s:=s+2*i+1;
write('tong la: ',s);
readln
end.
Câu 2
Bài 5:
Var b:array:[1..1000] of integer;
i,n,max:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(b[i]);
End;
Write('Cac phan tu am la: ');
For i:=1 to n dko
if b[i]<0 then write(b[i]:8);
writeln;
max:=b[1];
For i:=2 to n do
If b[i] > max then max:=b[i];
write('So lon nhat la ',max);
Readln
End.