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[1000],n,i;
int main()
{
freopen("dayd.inp","r",stdin);
freopen("dayd.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]>0) cout<<a[i]<<" ";
return 0;
}
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long n,i;
//chuongtrinhcon
int demuoc(long long n)
{
int dem=0;
for (long long i=1; i<=n; i++)
if (n%i==0) dem++;
return (dem);
}
//chuongtrinhchinh
int main()
{
freopen("tamuoc.inp","r",stdin);
freopen("tamuoc.out","w",stdout);
cin>>n;
long long dem=0;
for (i=1; i<=n; i++)
if (demuoc(i)==3) dem++;
cout<<dem;
return 0;
}
1.
#include <bits/stdc++.h>
using namespace std;
int A,n,i;
int main()
{
cin>>n;
A=0;
For (i=0;i<=n;i++)
A=A+1/i;
cout<<A;
Return 0;
}
Program HOC24;
const fi='Cau1.INP';
fo='Cau2.OUT';
var i,a,b,c,t,d: integer;
f: text;
function ucln(x,y: integer): integer;
var t: integer;
begin
while y<>0 do
begin
t:= x mod y;
x:=y;
y:=t;
end;
ucln:=x;
end;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,a,b,c);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
for i:=b to c do
begin
if i mod a=0 then write(f,i,' ');
t:=t+i;
end;
writeln(f);
while t<>0 do
begin
t:=t div 10;
inc(d);
end;
writeln(f,d);
if ucln(a,b,c)=1 then write(f,1) else write(f,0);
close(f);
end;
begin
ip;
out;
end.
Bài 1:
const fi='robot.inp';
fo='robot.out';
var f1,f2:text;
n,i,t:integer;
a:array[1..10000]of integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
t:=0;
for i:=1 to n do
begin
if a[i]=1 then t:=t+1
else t:=t-1;
end;
writeln(f2,t);
close(f1);
close(f2);
end.