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 a:array[1..100] of integer;
i,s:integer;
Begin
For i:=1 to 100 do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
If a[i] mod 2 <> 0 then s:=s+a[i];
End;
Write('Tong la ',s);
Readln;
End.
uses crt;
var s:string;
i,d,dem:integer;
begin
clrscr;
write('Nhap xau S:'); readln(s);
d:=length(s);
writeln('Cac ki tu so co trong xau S:');
dem:=0;
for i:=1 to d do
if s[i] in ['0'..'9'] then
begin
write(s[i]:4);
inc(dem);
end;
writeln;
writeln('So ki tu chu so co trong xau S: ',dem);
for i:=1 to d do
if s[i] in ['0'..'9'] then s[i]:='A';
writeln('Xau sau khi doi la: ',s);
readln;
end.
uses crt;
var a:array[1..10]of integer;
i,n,dem:integer;
begin
clrscr;
for i:=1 to 10 do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]>0;
end;
writeln('Day so vua nhap la: ');
for i:=1 to 10 do
write(a[i]:4);
dem:=0;
for i:=1 to n do
if a[i] mod 2=0 then inc(dem);
writeln;
writeln('So luong so chan la: ',dem);
readln;
end.
Câu 8:
#include <bits/stdc++.h>
using namespace std;
long long a[250],n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
sort(a+1,a+n+1);
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
Đề 3:
Câu 2:
#include <bits/stdc++.h>
using namaspace std;
long long x,n,i,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0 && i%2!=0) dem++;
}
cout<<dem;
return 0;
}
đề 1
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n,i,x,ans=0,cnt3=0,cnt5=0;
cin>>n;
for(i=0;i<n;i++)
{
cin>>x;
if(x%3==0)
cnt3++;
if(x%5==0)
cnt5++;
}
cout<<"so luong phan tu chia het cho 3 la: "<<cnt3;
cout<<"\nso luong phan tu chia het cho 5 la: "<<cnt5;
return 0;
}
Câu 4:
fucntion tong(x:integer):integer;
var st:string;
d,i,n,y,t:integer;
begin
str(x,st);
d:=length(st);
t:=0;
for i:=1 to d do
begin
val(st[i],n,y);
t:=t+n;
end;
tong:=t;
end;
Câu 2:
const fi='bai2.inp';
fo='bai2.out';
var f1,f2:text;
a:array[1..100]of integer;
n,i,t: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
t:=t+a[i];
writeln(f2,t);
close(f1);
close(f2);
end.
Câu 1:
const fi='dulieu.dat';
fo='thaythe.out';
var f1,f2:text;
a:array[1..100]of string;
n,d,i,vt:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eof(f1) do
begin
n:=n+1;
readln(f1,a[n]);
end;
for i:=1 to n do
begin
d:=length(a[i]);
vt:=pos('anh',a[i]);
while vt<>0 do
begin
delete(a[i],vt,3);
insert('em',a[i],vt);
vt:=pos('anh',a[i]);
end;
end;
for i:=1 to n do
writeln(f2,a[i]);
close(f1);
close(f2);
end.
Câu 2:
uses crt;
const fi='mang.inp';
fo='sapxep.out';
var f1,f2:text;
a:array[1..100]of integer;
i,n,tam,j:integer;
begin
clrscr;
assign(f1,fi); rewrite(f1);
assign(f2,fo); rewrite(f2);
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
write(f1,a[i]:4);
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(f2,a[i]:4);
close(f1);
close(f2);
end.