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.
uses crt;
var s:string;
i,tong,x,code:integer;
f,g:text;
k:boolean;
const fi='XAU.INP';
fo='XAU.OUT';
begin
k:=false;
assign(f,fi); reset(f);
assign(g,fo); rewrite(g);
readln(f,s);
tong:=0;
for i:=1 to length(s) do
begin
if s[i] in ['0'..'9'] then
begin
k:=true;
val(s[i],x,code);
tong:=tong+x;
x:=0;
cod:=0;
end;
end;
if k=false then writeln(g,'Sai yeu cau')
else
begin
writeln(g,s);
writeln(g,tong);
end;
close(f);
close(g);
end.
Câu 1:
#include <bits/stdc++.h>
using namespace std;
long long i,n,k,dem,x;
int main()
{
cin>>n;
cin>>k;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x==k) dem++;
}
cout<<dem;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
string st;
int d,i,dem;
int main()
{
freopen("xau.inp","r",stdin);
freopen("xau.out","w",stdout);
cin>>st;
d=st.length();
dem=0;
for (i=0; i<=d-1; i++)
if (st[i]=='a') dem++;
cout<<dem;
return 0;
}
Câu 7:
const fi='dayso.inp';
fo='dayso.out';
var f1,f2:text;
a,b:array[1..100]of integer;
i,n,dem,j,t,kt,dem1: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,'Tong cua day so la: ',t);
b[1]:=a[1];
dem:=1;
for i:=1 to n do
begin
kt:=0;
for j:=1 to dem do
if a[i]=b[j] then kt:=1;
if kt=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
end;
for i:=1 to dem do
begin
dem1:=0;
for j:=1 to n do
if b[i]=a[j] then inc(dem1);
writeln(f2,b[i],' xuat hien ',dem1,' lan');
close(f1);
close(f2);
end.
Câu 2:
uses crt;
var a,b:array[1..100]of integer;
i,n,t,dem,j,kt,dem1:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
readln(a[i]);
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t);
dem:=1;
b[1]:=a[1];
for i:=1 to n do
begin
kt:=0;
for j:=1 to dem do
if b[j]=a[i] then kt:=1;
if kt=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
end;
for i:=1 to dem do
begin
dem1:=0;
for j:=1 to n do
if a[j]=b[i] then inc(dem1);
writeln(b[i],' xuat hien ',dem1,' lan');
end;
readln;
end.