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.
Câu 1:
uses crt;
var n,i,t1,t2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t1:=0;
t2:=0;
for i:=1 to n do
begin
t1:=t1+i;
if i mod 2=0 then t2:=t2+i;
end;
writeln('Tong cac so tu 1 den ',n,' la: ',t1);
writeln('Tong cac so chan tu 1 den ',n,' la: ',t2);
readln;
end.
Câu 2:
uses crt;
var a,b,i,bcnn:longint;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
bcnn:=a*b;
for i:=a*b-1 downto 1 do
if (i mod a=0) and (i mod b=0) then
begin
if bcnn>i then bcnn:=i;
end;
writeln(bcnn);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long s,i,n;
int main()
{
cin>>n;
s=0;
for (i=1; i<=n; i++)
if (i%2==1) s=s+i*i;
cout<<s;
return 0;
}
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
s:=0;
for i:=1 to n do
s:=s+a[i];
writeln(s);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,j,tam:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.
uses crt;
var s:real;
i,n:integer;
begin
clrscr;
readln(n);
s:=0;
for i:=1 to n do
s:=s+(n*(n+1))/((n+2)*(n+3));
writeln(s:4:2);
readln;
end.
program TongN;
var
n, i, sum: integer;
begin
writeln('Nhap vao so n: ');
readln(n);
sum := 0;
for i := 1 to n do
begin
sum := sum + i;
end;
writeln('Tong S = ', sum);
readln;
end.
Tham khảo:
Uses Crt ;
Var i , n : Integer ;
tong: Real ;
BEGIN
Clrscr ;
Write (‘ Cho so tu nhien n : ‘) ; Readln (n) ;
tong :=0 ;
i :=1 ;
While i <= n Do
Begin
tong := tong + 1/i ;
i := i + 1 ;
End ;
Writeln (‘ Tong can tim la : ‘, tong:12:6 ) ;
Readln ;
END .