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.
Bài 2:
#include <bits/stdc++.h>;
using namespace std;
int main();
{
long m,n;
cout<<"Nhap m="; cin>>m;
cout<<"Nhap n="; cin>>n;
cout<<m*n-2;
return 0;
}
Bài 2:
#include <bits/stdc++.h>
using namespace std;
string st;
int d;
int main()
{
getline(cin,st);
d=st.length();
cout<<d;
return 0;
}
Bài 1:
Var so,i,n,dem:integer;
Begin
Write('Nhap so luong so n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i);readln(so);
If so mod 2 = 0 then dem:=dem+1;
End;
Write('Co ',dem,' so chan');
Readln;
End.
Bài 2:
Var st:string;
Begin
Write('Nhap vao xau ki tu ');readln(st);
Write(' Xau vua nhap co do dai la ',length(st));
Readln;
End.
1:
uses crt;
var a,b,i,tsc,tsl:integer;
begin
clrscr;
write('nhap a='); readln(a);
write('nhap b='); readln(b);
if (a>0) and (b>0) then
begin
if a<b then
begin
tsc:=0;
tsl:=0;
for i:=a to b do
if i mod 2=0 then tsc:=tsc+i
else tsl:=tsl+i;
writeln('tong cac so chan trong khoang tu ',a,' toi ',b,' la: ',tsc);
writeln('tong cac so le trong khoang tu ',a,' toi ',b,' la: ',tsl);
end
else writeln('vui long nhap a be hon b');
end
else writeln('vui long nhap hai so duong');
readln;
end.
2:
uses crt;
var n,i:integer;
begin
clrscr;
write('n='); readln(n);
if (n>=5) then
begin
writeln('cac so nguyen le trong khoang tu 5 toi ',n,' la: ');
for i:=5 to n do
if i mod 2=1 then write(i:4);
end
else writeln('vui long nhap n lon hon hoac bang 5');
readln;
end.
3:
uses crt;
var m,n,i:integer;
s:longint;
begin
clrscr;
write('m='); readln(m);
write('n='); readln(n);
if (m>0) and (n>0) then
begin
if m<n then
begin
s:=1;
for i:=m to n do
if i mod 2=0 then s:=s*i;
writeln('tich cac so chan trong pham vi tu ',m,' toi ',n,' la: ',s);
end
else writeln('vui long nhap m nho hon n');
end
else writeln('vui long nhap hai so duong');
readln;
end.
4:
uses crt;
var x,y,i,j:integer;
begin
clrscr;
write('x='); readln(x);
write('y='); readln(y);
if (x>0) and (y>0) then
begin
if x<y then
begin
writeln('day cac so nguyen duong trong pham vi tu ',x,' toi ',y,' la:');
for i:=x to y do
write(i:4);
writeln;
writeln('day cac so nguyen duong trong pham vi tu ',y,' toi ',x,' la:');
for j:=y downto x do
write(j:4);
end
else writeln('vui long nhap x nho hon y');
end
else writeln('vui long nhap hai so duong');
readln;
end.
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n,kt,max,x,j,tam:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Mang ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
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;
writeln('Day tang dan la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
write('Nhap x='); readln(x);
max:=0;
kt:=0;
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]<=x) then
begin
if max<a[i] then max:=a[i];
kt:=1;
end;
if kt=0 then writeln('Trong day khong co so le')
else writeln('So chan lon nhat khong vuot qua ',x,' la: ',max);
readln;
end.
cau 1:
uses crt;
var a:array[1..100] of integer;
n,i,min: integer;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
min:=a[1];
for i:=2 to n do
if min>a[i] then min=a[i];
writeln(a[i]);
readln;
end.
cau 2:
uses crt;
g:text;
s:string;
const fo='CHUSO.TXT';
begin
assign(g,fo);
rewrite(g);
readln(s);
for i:=1 to length(s) do
if not((s[i] in ['a'..'z'])and(s[i] in ['A'..'Z])) then delete(s,i,1);
writeln(g,s);
end.
Câu 1:
uses crt;
var st:string;
i,dem,d:integer;
vt:array[1..255]of integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
dem:=0;
for i:=1 to d do
if st[i]=' ' then
begin
inc(dem);
vt[dem]:=i;
end;
writeln('So luong ki tu trang la: ',dem);
write('Vi tri:');
for i:=1 to dem do
write(vt[i]:4);
readln;
end.
Câu 2:
uses crt;
var st:string;
i,dem,d:integer;
vt:array[1..255]of integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
dem:=0;
for i:=1 to d do
if st[i]<>' ' then
begin
inc(dem);
vt[dem]:=i;
end;
writeln('So luong ki tu khac ki tu trang la: ',dem);
write('Vi tri:');
for i:=1 to dem do
write(vt[i]:4);
readln;
end.
Câu 3:
uses crt;
var a:array[1..50]of integer;
n,i,max,min:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=50);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until (0<=a[i]) and (a[i]<=32767);
end;
writeln('Day so ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('Vi tri cua gia tri lon nhat la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
writeln;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln('Vi tri cua gia tri nho nhat la: ');
for i:=1 to n do
if min=a[i] then write(i:4);
readln;
end.