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ách 1: Có sử dụng chương trình con
uses crt;
var st:string;
{------------chuong-trinh-con-------------------}
function doi(st1:string):string;
var i,d:integer;
begin
d:=length(st1);
for i:=1 to d do
st1[i]:=upcase(st1[i]);
doi:=st1;
end;
{-------------------chuong-trinh-chinh--------------------}
begin
clrscr;
write('Nhap xau:'); readln(st);
writeln(doi(st));
readln;
end.
Cách 2: Không sử dụng chương trình con
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
st[i]:=upcase(st[i]);
writeln(st);
readln;
end.
*Cách có sử dụng chương trình con:
uses crt;
var st:string;
{--------------chuong-trinh-con---------------}
function doixau(st:string):string;
var i,d:integer;
begin
d:=length(st);
for i:=1 to d do
st[i]:=upcase(st[i]);
doixau:=st;
end;
{-------------chuong-trinh-chinh---------------}
begin
clrscr;
write('Nhap xau:'); readln(st);
writeln('Xau doi sang chu hoa la: ',doixau(st));
readln;
end.
*Cách không sử dụng chương trình con:
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
st[i]:=upcase(st[i]);
writeln('Xau sau khi doi la: ',st);
readln;
end.
Uses crt;
Var dai,rong:integer;
Procedure Nhap(Var dai:integer;rong:integer);
Begin
Write('Chieu dai: ');readln(dai);
Write('Chieu rong: ');readln(rong);
End;
Procedure Ve(var dai:integer;rong:integer);
var i,j:integer;
Begin
for i:= 1 to dai do write('*');writeln;
For i:= 1 to rong-2 do
Begin
Write('*');
for j:=1 to dai-2 do write(' ');
writeln('*');
end;
for i:= 1 to dai do write('*');
End;
Begin
clrscr;
Nhap(dai,rong);
Ve(dai,rong);
readln;
End.
uses crt;
var a,t,dem:integer;
begin
clrscr;
t:=0;
dem:=0;
repeat
write('Nhap a='); readln(a);
if (a mod 2=0) and (a mod 3=0) then
begin
t:=t+a;
dem:=dem+1;
end;
until a=0;
writeln('Trung binh cong cua cac so chia het cho 3 va 2 la: ',t/dem:4:2);
readln;
end.
1:
uses crt;
const fi='ketqua.txt';
var f1:text;
st:string;
i,d:integer;
begin
clrscr;
assign(f1,fi); rewrite(f1);
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
writeln(f1,st);
close(f1);
end.
2:
uses crt;
var a,b,c,d:integer;
{----------chuong-trinh-con-----------------------}
function min(x,y:integer):integer;
begin
if x<y then min:=x
else min:=y;
end;
{---------------chuong-trinh-chinh--------------------}
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
write('c='); readln(c);
write('d='); readln(d);
writeln(min(a,min(b,min(c,d))));
readln;
end.
uses crt;
var a,b:integer;
{---------------ve-hinh-chu-nhat---------------------}
procedure ve(x,y:integer);
var i,j:integer;
begin
for i:=1 to x do
begin
for j:=1 to y do
write('*');
writeln;
end;
end;
{------------------chuong-trinh-chinh---------------}
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
ve(a,b);
writeln;
ve(2*a,2*b);
writeln;
ve(3*a,3*b);
readln;
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.
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long n,i,j,m;
int main()
{
cin>>n>>m;
for (i=1; i<=n; i++)
{
for (j=1; j<=m; j++)
{
if (i==1 || j==1|| i==n|| j==m) cout<<"*";
else cout<<" ";
}
cout<<endl;
}
return 0;
}
uses crt;
var a,b,i,j:integer;
st:string;
begin
clrscr;
repeat
write('Ban muon ve khong:'); readln(st);
if st='Yes' then
begin
write('Nhap chieu dai:'); readln(a);
write('Nhap chieu rong:'); readln(b);
for i:=1 to a do
begin
for j:=1 to b do
write('*');
writeln;
end;
end
else break;
until st='No';
readln;
end.