summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/c-pascal/prog
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-09 00:56:57 +0000
committerKarl Berry <karl@freefriends.org>2006-01-09 00:56:57 +0000
commitf07bb53970ee2ecc53f81a206a3d3a67ef665e4a (patch)
tree6f57a1d62971db79e5ff023bdfd83b22cb971dc9 /Master/texmf-dist/doc/generic/c-pascal/prog
parent007f67a693e4d031fd3d792df8e4d5f43e2cb2e7 (diff)
doc 6
git-svn-id: svn://tug.org/texlive/trunk@85 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/generic/c-pascal/prog')
-rw-r--r--Master/texmf-dist/doc/generic/c-pascal/prog/guess.pas26
-rw-r--r--Master/texmf-dist/doc/generic/c-pascal/prog/sun.c39
2 files changed, 65 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/generic/c-pascal/prog/guess.pas b/Master/texmf-dist/doc/generic/c-pascal/prog/guess.pas
new file mode 100644
index 00000000000..743f297622e
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/c-pascal/prog/guess.pas
@@ -0,0 +1,26 @@
+program guess;
+
+var
+ num1, num2: integer;
+
+begin
+ randomize;
+ num2 := random(100);
+
+ repeat
+ { make user guess }
+ write('Guess my number: ');
+ readln(num1);
+
+ { check the relation }
+ if num1 = num2 then
+ writeln('Very well!');
+ if num1 < num2 then
+ writeln('Too small.');
+ if num1 > num2 then
+ writeln('Too big.');
+ until num1 = num2;
+
+ { pause }
+ readln;
+end.
diff --git a/Master/texmf-dist/doc/generic/c-pascal/prog/sun.c b/Master/texmf-dist/doc/generic/c-pascal/prog/sun.c
new file mode 100644
index 00000000000..889341b5b9d
--- /dev/null
+++ b/Master/texmf-dist/doc/generic/c-pascal/prog/sun.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <math.h>
+
+int months[]={0, 31, 28, 31, 30, 31, 30,
+ 31, 31, 30, 31, 30, 31};
+char weekdays[7][15]={"Sunday", "Monday", "Tuesday", "Wednesday",
+ "Thursday", "Friday", "Sunday"};
+
+/* this program calculates the latidude
+ where polar day begins/ends */
+void main()
+{
+ int day=24, month=6, weekday=2;
+ double angle=0;
+ double latitude;
+
+ do
+ {
+ latitude=atan(tan((23+27.0/60)*M_PI/180)*cos(angle))*180/M_PI;
+ latitude=(latitude>0)? 90-latitude : -90-latitude;
+ printf("%2d.%02d %12s : %d %02d'\n", day, month,
+ weekdays[weekday], (int)latitude,
+ (int)fabs((latitude-(int)latitude)*60));
+ if (weekday==0)
+ printf("\n");
+
+ angle+=2*M_PI/365;
+ day++;
+ if (day>months[month])
+ {
+ day=1;
+ month++;
+ if (month>12)
+ month=1;
+ }
+ if (++weekday>6)
+ weekday=0;
+ } while (month!=1);
+}