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:
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.
uses crt;
const fo='xau.out';
var f1:text;
s1,s2:string;
d1,d2,dem:integer;
begin
clrscr;
assign(f1,fo); rewrite(f1);
write('Nhap xau s1:'); readln(s1);
write('Nhap xau s2:'); readln(s2);
d1:=length(s1);
d2:=length(s2);
writeln('Do dai xau ',s1,' la: ',d1);
writeln('Do dai xau ',s2,' la: ',d2);
dem:=0;
while pos(s2,s1)>0 do
begin
inc(dem);
delete(s1,pos(s2,s1),length(s2));
end;
writeln(f1,s1);
writeln(f1,s2);
writeln(f1,'So lan xuat hien cua xau s2 trong xau s1 la: ',dem);
close(f1);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long a[100],n,i,t,s;
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
t=0;
s=1;
for (i=1; i<=n; i++)
{
t=t+a[i];
s=s*a[i];
}
cout<<"Tong la:"<<t<<endl;
cout<<"Tich la:"<<s<<endl;
return 0;
}
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long n,i,a[1000],x;
int main()
{
freopen("bai2.inp","r",stdin);
freopen("bai2.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]%2==0)
{
x=a[i];
break;
}
cout<<x<<endl;
for (i=1; i<=n; i++)
if (a[i]==x) cout<<i<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[10000],n,i;
int main()
{
freopen("bai2.inp","r",stdin);
freopen("bai2.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=n; i>=1; i--) cout<<a[i]<<" ";
return 0;
}
Lỗi hình ảnh kìa bạn êy