- 14 Tháng năm 2017
- 3,974
- 7,627
- 744
- 22
- Phú Yên
- Trường THPT Lương Văn Chánh


Cái này học được trên mạng rồi về làm đó, chỉ là bói vui thôi
tạo hi vọng cho những ai chưa có người yêu (như tui chẳng hạn
)
Code đơn giản mà hiệu quả.
Còn đây là hình ảnh Demo

Code đơn giản mà hiệu quả.
Mã:
Program Loves;
uses crt;
const _Loves : array[1..5] of char = ('L','O','V','E','S');
var nam,nu,ketqua: string;
SoGiong: integer;
i,j: integer;
function ToInt(s: string): longint;
var i: longint;
code: integer;
Begin
Val(s,i,code);
if code = 0 then
ToInt := i
else ToInt := 0;
End;
function ToString(i: longint): string;
var s: string;
Begin
Str(i,s);
ToString := s;
End;
Function Sum(so: string): longint;
var i,dau: integer;
s: string;
Begin
sum := 0;
while (ToInt(so) > 100) do
begin
dau := ToInt(so[1]);
s := '';
for i := 2 to Length(so) do
begin
s := s + ToString(dau + ToInt(so[i]));
end;
so := s;
end;
Sum := ToInt(so);
End;
BEGIN
clrscr;
TextColor(Green);
write('Nhap ho ten nguoi nam : ');readln(nam);
TextColor(Cyan);
write('Nhap ho ten nguoi nu : ');readln(nu);
KetQua := '';
for i := 1 to 5 do
begin
SoGiong := 1;
for j := 1 to length(nam) do
begin
nam[j] := Upcase(nam[j]);
if nam[j] = _Loves[i] then
inc(SoGiong);
end;
for j := 1 to length(nu) do
begin
nu[j] := UpCase(nu[j]);
if nu[j] = _Loves[i] then
inc(SoGiong);
end;
Ketqua := KetQua + ToString(SoGiong);
end;
TextColor(LightRed);
Writeln('Ket qua la: ',Sum(KetQua),'%');
readln;
END.
Còn đây là hình ảnh Demo

Last edited: