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.
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.
Câu 2:
uses crt;
var a,b:integer;
begin
clrscr;
readln(a,b);
writeln('Tong a+b la ',a+b);
writeln('Hieu a-b la ',a-b);
writeln('Tich cua a*b la ',a*b);
writeln('Thuong cua a/b la ',a/b:4:2);
readln;
end.
Câu 2: (C++)
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
cout << "Tong a+b la: " << a+b << "\nHieu a-b la: " << a-b << "\nTich a*b la: " << a*b << "\nThuong a/b la: " << (double)a/b << endl;
return 0;
}
Chúc bn học tốt!
Câu 1:
#include <bits/stdc++.h>
using namespace std;
long long a,b,dem,i;
int main()
{
cin>>a>>b;
dem=0;
for (i=a; i<=b; i++)
if (i%2==0) dem++;
cout<<dem;
return 0;
}
Uses crt;
Const fi='dl.int';
Var f1:text;
A:array[1..100] of integer;
I,n,t: integer;
Begin
Clrscr;
Assign(f1,fi); reset(f1);
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(t);
Close(f1);
Readln;
End.
uses crt;
var a:array[1..100]of integer;
i,n,dem1,dem2,t1,t2,sa,sd,vt1,vt2:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
dem1:=0;
t1:=0;
dem2:=0;
t2:=0;
for i:=1 to n do
begin
if a[i]>0 then begin inc(dem1); t1:=t1+a[i]; end;
if a[i]<0 then begin inc(dem2); t2:=t2+a[i]; end;
end;
writeln(dem1);
writeln(dem2);
writeln(t1);
writeln(t2);
for i:=1 to n do
if a[i]>0 then
begin
sd:=a[i];
vt1:=i;
break;
end;
if (dem1=0) then writeln('Khong co so duong trong day')
else writeln('So duong dau tien la: ',sd,' vi tri la: ',vt1);
for i:=1 to n do
if a[i]<0 then
begin
sa:=a[i];
vt2:=i;
break;
end;
if (dem2=0) then writeln('Khong co so am trong day')
else writeln('So am dau tien la: ',sa,' vi tri la: ',vt2);
readln;
end.
uses crt;
var st:string;
i,d,dem:integer;
begin
clrscr;
readln(st);
d:=length(st);
dem:=0;
for i:=1 to d do
if st[i]=' ' then dem:=dem+1;
writeln(dem+1);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cout<<"Nhap nam:"; cin>>n;
if (n%400==0) cout<<"Co 366 ngay";
else if ((n%4==0) and (n%100!=0)) cout<<"Co 366 ngay";
else cout<<"Co 365 ngay";
return 0;
}