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.
const fi='kt.txt';
fo='kq.out';
var f1,f2:text;
s:string;
i,dem,d:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,s);
d:=length(s);
dem:=0;
for i:=1 to d do
if s[i]='e' then inc(dem);
writeln(f2,dem);
close(f1);
close(f2);
end.
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.
#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;
}
#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;
}
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;
}
uses crt;
var m:integer;
begin
clrscr;
write('Nhap m='); readln(m);
if m mod 2=0 then writeln(m,' la so chan')
else writeln(m,' la so le');
writeln('Binh phuong cua ',m,' la: ',sqr(m));
writeln('Can bac hai cua ',m,' la: ',sqrt(m));
writeln('Gia tri tuyet doi cua ',m,' la: ',abs(m));
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,t1,dem:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do
if a[i]>0 then t:=t+a[i];
t1:=0;
for i:=1 to n do
if (a[i]>0) and (a[i] mod 2<>0) then t1:=t1+a[i];
dem:=0;
for i:=1 to n do
if a[i]>0 then dem:=dem+1;
writeln(t);
writeln(t1);
writeln(dem1);
readln;
end.