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.
![](https://rs.olm.vn/images/avt/0.png?1311)
#include <bits/stdc++.h>
using namespace std;
long long n,i,dem,t;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n; i++)
if (i%2==1)
{
t=t+i;
dem++;
}
cout<<t<<" "<<dem;
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
#include <bits/stdc++.h>
using namespace std;
long long n,i,dem,t;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n; i++)
if (i%2==0)
{
t=t+i;
dem++;
}
cout<<t<<" "<<dem;
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
#include <bits/stdc++.h>
using namespace std;
long long x,i,n,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if ((x%2==0) or (x%5==0)) dem++;
}
cout<<dem;
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so chan la: ');
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
write(a[i]:4);
t:=t+a[i];
inc(dem);
end;
writeln('Tong cac so chan la: ',t);
writeln('Trong day co ',dem,' so chan');
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var a:array[1..200]of integer;
i,n,tbc,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so duong chan la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]>0) then write(a[i]:4);
writeln;
tbc:=0;
dem:=0;
for i:=1 to n do
if (-1000<=a[i]) and (a[i]<=1000) then
begin
tbc:=tbc+a[i];
dem:=dem+1;
end;
writeln('Trung binh cong cac phan tu co gia tri trong pham vi tu -1000 den 1000 la: ',tbc/dem:4:2);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var a:array[1..1000]of integer;
i,n,k,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
for i:=1 to n do
if a[i]=k then
begin
writeln(i);
break;
end;
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
if dem>0 then writeln('Co ',dem,' phan tu bang ',k)
else writeln('Khong co phan tu nao bang ',k);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,dem1,dem2;
int main()
{
cin>>n;
dem1=0;
dem2=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) dem1++;
else dem2++;
}
cout<<dem1<<" "<<dem2;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long i,n,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
int x=sqrt(i);
if (x*x==i)
{
dem++;
cout<<i<<" ";
}
}
cout<<endl;
cout<<dem;
return 0;
}
bạn ơi cái code này hơi chậm, bạn có thể sử dụng code này :)
#include <bits/stdc++.h>using namespace std;
int main(){
long long i;
cin >> i;
long long n = 1;
int counter = 0;
int additional = 3;
while (n<=i){
counter = counter +1;
n= n + additional;
additional = additional + 2;
}
cout << counter;
}