Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
#include <bits/stdc++.h>
using namespace std;
long long a[100],i,n,t,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;
t=0;
for (i=1; i<=n; i++) if (a[i]%2==0) t+=a[i];
nn=a[1];
for (i=1; i<=n; i++)
nn=min(nn,a[i]);
cout<<t<<endl;
cout<<nn<<endl;
cout<<a[1]+a[n];
return 0;
}
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n,min:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
Bài 2:
uses crt;
var a:array[1..100]of integer;
i,n,max:integer;
begin
clrscr;
write('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.
program SoChanDenN;
var
n, i: Integer;
begin
Write('Nhap n: ');
Readln(n);
Write('Cac so chan tu 1 den ', n, ' la: ');
for i := 1 to n do
begin
if i mod 2 = 0 then
Write(i, ' ');
end;
end.
1. Uses crt;
var n,i: integer;
begin clrscr;
readln(n);
for i:=1 to n do write(i:3);
readln;
end.
2. Uses crt;
var n,i: integer;
begin clrscr;
readln(n);
for i:=1 to n do if(i mod 2 = 0) then write(i:3);
readln;
end.
program BaiTap;
var
A: array[1..150] of integer;
N, i, sum: integer;
begin
write('Nhap so phan tu cua day A (N <= 150): ');
readln(N);
for i := 1 to N do
begin
write('Nhap phan tu thu ', i, ': ');
readln(A[i]);
end;
writeln('Day so vua nhap la:');
for i := 1 to N do
write(A[i], ' ');
writeln;
sum := 0;
for i := 1 to N do
if A[i] mod 2 = 0 then
sum := sum + A[i];
writeln('Tong cac phan tu chan trong day la: ', sum);
readln;
end.
a)
program UCLN_va_BCNN;
uses crt;
var a,b,c,r,p:integer;
begin
clrscr;
write('nhap a,b:');readln(a,b);
if a<b then
begin
c:=a;
a:=b;
b:=c;
end;
p:=a*b;
r:=a mod b;
while r<>0 do
begin
a:=b;
b:=r;
r:=a mod b;
end;
writeln('UCLN la: ',b);
writeln('BCNN la: ',p div b);
readln;
end.
b)
program fibonaci;
uses crt;
var i,n:integer;
a:array[1..30]of integer;
begin
clrscr;
repeat
write('nhap n:');readln(n);
if (n<1)or(n>30) then writeln('so n phai lon hon hoac bang 1 va nho hon hoac bang 30:);
until (n>=1)and(n<=30);
a[1]:=1;
a[2]:=1;
for i:=3 to n do
a[i]:=a[i-1]+a[i-2];
writeln(n,' so fibonaci dau tien la:');
for i:=1 to n do
write(a[i]:3);
readln;
end.