type Week_Days_Type is array (1..7) of String(1..8);
Week_Days : Week_Days_Type := ("星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日");
function Get_Week_Day(Day_Index : Integer) return String is
begin
return Week_Days(Day_Index);
end Get_Week_Day;
Put_Line(Get_Week_Day(1)); -- 输出:星期一
Put_Line(Get_Week_Day(7)); -- 输出:星期日
完整代码如下所示:
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
type Week_Days_Type is array (1..7) of String(1..8);
Week_Days : Week_Days_Type := ("星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日");
function Get_Week_Day(Day_Index : Integer) return String is
begin
return Week_Days(Day_Index);
end Get_Week_Day;
begin
Put_Line(Get_Week_Day(1)); -- 输出:星期一
Put_Line(Get_Week_Day(7)); -- 输出:星期日
end Main;