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.
Var n,sc,sl,i:longint;
Begin
Write('N = ');readln(n);
Write('Cac so tu 1 den ',n,' la ');
For i:=1 to n do
Write(i:8);
Writeln;
For i:=1 to n do
Begin
If i mod 2 = 0 then sc:=sc+i
Else sl:=sl+i;
End;
Writeln('Tong cac so chan la ',sc);
Write('Tong cac so le la ',sl);
Readln
End.
1:
#include <bits/stdc++.h>
using namespace std;
long long a[100],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
cout<<"Day ban dau la: "<<endl;
for (i=1;i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
sort(a+1,a+n+1);
cout<<"Day tang dan la: "<<endl;
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
a)
uses crt;
var a:array[1..20] of integer;
i,dem,t:integer;
begin
clrscr;
for i:=1 to 20 do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac phan tu chia het cho 3:');
for i:=1 to 20 do
if a[i] mod 3=0 then write(a[i]:4);
writeln;
dem:=0;
t:=0;
for i:=1 to 20 do
if a[i]>0 then
begin
dem:=dem+1;
t:=t+a[i];
end;
writeln('Trung binh cong cac phan tu nguyen duong la: ',t/dem:4:2);
readln;
end.
b)
uses crt;
var a:array[1..30] of integer;
i,dem,t:integer;
begin
clrscr;
for i:=1 to 30 do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to 30 do
if a[i] mod 5=0 then
begin
dem:=dem+1;
t:=t+a[i];
end;
writeln('Trung binh cong cac phan tu chia het cho 5 la: ',t/dem:4:2);
readln;
end.
c)
uses crt;
var a:array[1..200]of integer;
i,n,max,min:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<201);
for i:=1 to n do
begin
write('A[',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('Phan tu lon nhat: ',max);
writeln('Phan tu nho nhat la: ',min);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a,b,bcnn;
int main()
{
cin>>a>>b;
if (a>b) swap(a,b);
bcnn=b;
while (bcnn%a!=0)
bcnn=bcnn+b;
cout<<bcnn;
return 0;
}