K
Khách

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.

15 tháng 7 2023

program count_days;

var

       a, b, c, x, y, z, days: integer;

function is_leap_year(year: integer): boolean;

begin

       if (year mod 4 = 0) and (year mod 100 <> 0) or (year mod 400 = 0) then

              is_leap_year := true

       else

              is_leap_year := false;

end;

function days_in_month(month, year: integer): integer;

begin

       case month of

              1, 3, 5, 7, 8, 10, 12: days_in_month := 31;

              4, 6, 9, 11: days_in_month := 30;

              2:

                     if is_leap_year(year) then

                            days_in_month := 29

                     else

                            days_in_month := 28;

       end;

end;

begin

       writeln('Nhap ngay a thang b nam c: ');

       readln(a, b, c);

       writeln('Nhap ngay x thang y cung nam c: ');

       readln(x, y, z);

       if (a > x) or ((a = x) and (b > y)) or ((a = x) and (b = y) and (c > z)) then

       begin

              writeln('Loi nhap lieu!');

              halt;

       end;

       days := days_in_month(b, c) - a + 1;

       while (b < y) or ((b = y) and (c < z)) do

       begin

              a := 1;

              b := b + 1;

              if b > 12 then

              begin

                     b := 1;

                     c := c + 1;

              end;

              days := days + days_in_month(b, c);

       end;

       days := days - (days_in_month(y, z) - x);

       writeln('So ngay giua hai ngay la: ', days);

end.

Dữ liệu ra: số ngày tương ứng

8 tháng 7 2023

program cho_xuat;

uses
  System.SysUtils, System.Classes, System.Generics.Collections;

type
  Tsum = record
    value: Integer;
  end;

  TsumArray = array of Tsum;

function cho_xuat(N: String; M: Integer): TsumArray;
begin
  SetLength(Result, Length(N));
  for i := 0 to High(Result) do
  begin
    if N[i] >= 58 then
      Result[i].value := Result[i].value + M
    else
      Result[i].value := Result[i].value - M;
  end;
end;

var
  N, M: String;
  a: TsumArray;
begin
    readln(N, M);
    a := cho_xuat(N, M);

    WriteLn('KQ: ' + N, ' -> ' + ConvertIntToString(M) + '');
    for i := 0 to High(a) do
    begin
        WriteLn(' + ', a[i].value, ' +', );
    end;
end.

1 tháng 7 2023

program  Nenxau;

var s: string;
        i, count: integer;
        c: char;

begin
  readln(s);
  count := 1;
  c := s[1];
  for i := 2 to length(s) do
    begin
      if s[i] = c then
        inc(count)
      else
        begin
          write(count);
          write(c);
          count := 1;
          c := s[i];
        end;
    end;
  write(count);
  write(c);
end.

uses crt;
var st,k,t:string;
    d,dem,i:integer;
begin

clrscr;

readln(st);

d:=length(st);

k='';

dem=1;

for i:=2 to d do

      begin 

        if st[i]=st[i-1] then inc(dem);

        if st[i]<>st[i-1] then

        btegin

          str(dem,t);

          if dem>1 then k:=k+t+st[i-1];

          else k:=k+st[i-1];

          dem=1;

        end;

        if (i=d) then 

           begin

           str(dem,t);

           if dem>1 then k:=k+t+st[i];

           else k:=k+st[i];

           end;

    end;

    write(k);

readln;

end.

9 tháng 8 2023

ABABUUC nén sai bạn ơi

 

29 tháng 6 2023

```pascal
program TimSoNguyenTrongSoN;
uses crt;

procedure TimSoNguyenTrongSoN(n: integer);
var
n_str: string;
so_nguyen_xuat_hien: array of integer;
temp: string;
i, j, so: integer;
begin
n_str := IntToStr(n);
SetLength(so_nguyen_xuat_hien, 0);

for i := 1 to Length(n_str) do
begin
temp := '';
for j := i to Length(n_str) do
begin
temp := temp + n_str[j];
if TryStrToInt(temp, so) then
begin
SetLength(so_nguyen_xuat_hien, Length(so_nguyen_xuat_hien) + 1);
so_nguyen_xuat_hien[Length(so_nguyen_xuat_hien) - 1] := so;
end;
end;
end;

writeln('Cac so nguyen xuat hien trong so ', n, ' la:');
for i := 0 to Length(so_nguyen_xuat_hien) - 1 do
begin
writeln(so_nguyen_xuat_hien[i]);
end;
end;

var
n: integer;
begin
clrscr;
write('Nhap vao so n: ');
readln(n);
TimSoNguyenTrongSoN(n);
readln;
end.
```

1 tháng 7 2023

sao mình ko chạy được v bạn

 

25 tháng 4 2018

Program Doi_Sang_Chu_Hoa;
Var S , SH: String; i : Byte;
Begin
Write('Nhap vao mot chuoi chu thuong : '); Readln(S);
SH := ''; {tạo xâu rỗng SH}
For i := 1 to Length(S) do SH[i] := UpCase(S[i];
Write('Chuoi da doi sang chu hoa: ',SH);
Readln;
End.

bạn dùng hàm UpCase(kí tự) để đổi từ chữ thường sang chữ hoa

25 tháng 4 2018

Program Chuoi_In_Hoa;
Uses Crt;
Var i:integer;st:string;

Begin
Clrscr;
Writeln(‘DOI CHUOI SANG CHUOI HOA’);
Write(‘Nhap ho ten:’);readln(st); st[1]:=upcase(st[1]);
For i:=1 to length(St) do
If st[i]=’ ‘ then st[i+1]:=upcase(st[i+1]); Writeln(‘Ho ten sau khi doi lan 1 la: ‘,st);
For i:=1 to length(St) do st[i]:=upcase(st[i]);
Writeln(‘Ho ten sau khi doi lan 2 la: ‘,st);

Readln;

End.

21 tháng 8 2023

program XoaSoLienTuc;

uses sysutils;

function XoaSoLienTuc(S: string): string;

var

     i: integer;

     result: string;

begin

     result := '';

     for i := 1 to Length(S) do

     begin

          if not (S[i] in ['0'..'9']) then

          begin

               if (i = 1) or (S[i-1] in ['0'..'9']) then

                    result := result + ' ';

               result := result + S[i];

          end;

     end;

     result := Trim(result);

     result := StringReplace(result, ' ', '', [rfReplaceAll]);

     XoaSoLienTuc := result;

end;

var

     S: string;

begin

     write('Nhập vào xâu S: ');

     readln(S);

     writeln('Kết quả: ', XoaSoLienTuc(S));

end.

21 tháng 8 2023

không ra bạn ơi