Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92374985
demo2.tex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 19, 19:26
Size
1 KB
Mime Type
text/x-c
Expires
Thu, Nov 21, 19:26 (2 d)
Engine
blob
Format
Raw Data
Handle
22431432
Attached To
R232 fabrepos2
demo2.tex
View Options
\input cap
\let\IdentifierColor=\Black
\let\KeywordColor=\MidnightBlue
\let\SpecialColor=\Black
\let\SymbolColor=\Black
\let\CommentColor=\Gray
\let\TextColor=\ForestGreen
\let\DirectiveColor=\Tan
\SpaceSkip=1.3ex
% Just for fun, you can use a cyrillic font for identifiers
% Of course, any font can be changed just like in the non-color
% version of cap.
%\font\cirm=wncyi10\let\IdentifierFont=\cirm
A short program in C. It was inserted directly into the \TeX\ source file.
\medskip
\BeginC
#include <stdio.h>
void main()
{
a=~a;
printf("Hello, world!\n");
// printf("Hello, world!\n");
}
\EndC
\hrule
\bigskip
And now a program inserted from a separate file.
\medskip
\InputC{prog/sun.c}
\vfill\eject
And now programs written in Pascal. This one was typed directly into this
file.
\medskip
\BeginPascal
program Hello_world;
begin
writeln('Hello, world!');
{ writeln('Hello, world!'); }
end.
\EndPascal
\hrule
\bigskip
This one was imported from another file.
\medskip
\InputPascal{prog/guess.pas}
\vfill\eject
And now, my latest addition: programs written in Python. The first one
is typed directly into the file.
\medskip
\BeginPython
def fib(n):
"""Calculates Fibonacci series.
It returns the first member of Fibonacci series larger than n"""
a,b=1,1
while b <= n:
a,b = b,a+b # see how we use multiple assignment?
return b
fib(10)
\EndPython
\hrule
\bigskip
This one was imported from another file.
\medskip
\InputPython{prog/fib.py}
\bye
Event Timeline
Log In to Comment