你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu 中的编程语言

Pascal

[日期:2010-08-11] 来源:Ubuntu社区  作者:skyivben [字体:大 中 小]

Pascal
Pascal 语言在2010年6月编程语言排行榜中排名第十五位。下面就是 GregorianTest.pas 程序:

Program GregorianTest(output);
type
  StringArray = array[0..6] of string[3];
var
  t: TimeStamp;
  a: StringArray;
procedure Init;
begin
  a[0] := "Sun";
  a[1] := "Mon";
  a[2] := "Tue";
  a[3] := "Wed";
  a[4] := "Thu";
  a[5] := "Fri";
  a[6] := "Sat";
end;
begin
  Init;
  GetTimeStamp(t);
  WriteLn(a[t.DayOfWeek], ' ', Date(t));
  t.Year := 1582;
  t.Month := 10;
  t.Day := 4;
  t.DayOfWeek := 4;
  WriteLn(a[t.DayOfWeek], ' ', Date(t));
end.

安装 GNU Pascal,编译和运行:

ben@ben-1520:~/work$ sudo apt-get install gpc
ben@ben-1520:~/work$ gpc --version
gpc 20070904, based on gcc-4.1.3 20080704 (prerelease) (Ubuntu 2.1-4.1.2-27ubuntu2)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
ben@ben-1520:~/work$ gpc -o GregorianTest GregorianTest.pas
ben@ben-1520:~/work$ ./GregorianTest
Wed 16 Jun 2010
Thu  4 Oct 1582
ben@ben-1520:~/work$

 
在 GNU Pascal 中,我没有找到计算某一日期是星期几的函数,也没有找到计算某一日期的下一天的函数。程序之所以能够正确输出星期四,是由于在 GregorianTest.pas 程序的第24行对 DayOfWeek 字段进行了赋值。

 

 

 

 

linux
【内容导航】
第1页:Java 第2页:Scala
第3页:Visual Basic.NET 第4页:C#
第5页:F# 第6页:C
第7页:C++ 第8页:Python
第9页:Ruby 第10页:JavaScript
第11页:Perl 第12页:PHP
第13页:Pascal 第14页:Delphi
第15页:Fortran 第16页:Lua
第17页:Lisp 第18页:Logo
相关资讯       Linux编程  Ubuntu编程 
本文评论   查看全部评论 (1)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款
第 1 楼
* long 发表于 2010/8/14 23:47:54
赞