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.
1:
uses crt;
var n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
t:=t+i*i;
write(t);
readln;
end.
2
program bt2;
var i,n,t:integer;
begin
readln(n);
s:=0;
for i:=1 to n do
if i mod 2 = 1 then s:=s+i;
readln;
end.
Bài 1
Var s,i:integer;
tb:real;
Begin
Write('Nhap n = ');readln(n);
i:=1;
s:=0;
While i<=n do
Begin
s:=s+i;
i:=i+1;
End;
tb:=s/n;
Writeln('Tong la ',s);
Write('Trung binh la ',tb:10:2);
Readln;
End.
Bài 2
Var i,n,souoc:integer;
Begin
Write('Nhap n = ');readln(n);
i:=1;
While i <= n do
Begin
i:=i + 1;
If n mod i = 0 then souoc:=souoc + 1;
End;
If souoc = 1 then write(n,' la so nguyen to')
Else write(n,' khong la so nguyen to');
Readln;
End.
uses crt;
var i,n,s:integer;
begin
clrscr;
readln(n);
s:=0;
i:=0;
while i<=n do
begin
i:=i+1;
s:=s+i*i;
end;
writeln(s);
readln;
end.
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.
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n: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 do
if a[i] mod 2<>0 then write(a[i]:4);
readln;
end.
Bài 2:
uses crt;
var a:array[1..100]of integer;
i,n: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 do
if a[i] mod 2=0 then write(a[i]:4);
readln;
end.
Câu 1:
uses crt;
var s,i:integer;
begin
clrscr;
s:=0;
for i:=1 to 10 do
s:=s+i;
writeln('Tong cua 10 so tu nhien dau tien la: ',s);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i]>0 then inc(dem);
writeln('So luong phan tu duong la: ',dem);
readln;
end.
Câu 3:
uses crt;
var i,j:integer;
begin
clrscr;
for i:=1 to 9 do
begin
writeln('Bang nhan ',i,' la: ');
for j:=1 to 10 do
writeln(i,'*',j,'=',i*j);
delay(200);
end;
readln;
end.
1:
#include <bits/stdc++.h>
using namespace std;
long long dem,i,n,x;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) dem++;
}
cout<<dem;
return 0;
}
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%3==0) t+=x;
}
cout<<t;
return 0;
}
Câu 1:
var i,n:integer;
s:longint;
begin
write('Nhap n = ');readln(n);
for i:=1 to n do
s:=s+(i*10+2);
write('S = ',s);
readln;
end.
Câu 2:
var i,n:integer;
s:real;
begin
write('Nhap n = ');readln(n);
for i:=1 to n do s:=s+1/n;
write('tong la ',s:10:2);
readln;
end.