Name: Anonymous 2010-06-17 15:14
Lets see if /prog/ can count to 10 in C. I'll start:
int main(void){
int main(void){
int i;
for (i = 1; i <= 10; ++i) printf("%d\n", i); return 0; }for(i=0; i < 10; i++)
i++
#include <stdmeme.h>
return(0);
strcpy(i[3], "Marshland");
#include <stdio.h>#include statement is. All the calls inside main will have been to functions that have as of yet undeclared.
[borat]Theis thread iz vary niiice![/borat]
#include <stdio.h> // all the libraries
#include <stdlib.h>
#include <ctype.h>
int main(void) //this is main, its the second most important function in this program
{
FILE *ofp; //input and output files
int i, k = 0;
printf("Enter how many data entries you wish to generate:");
scanf("%d", &k);
char adj1[10][25];
char adj2[10][25];
char adj3[10][25];
char city[10][25];
strcpy(adj1[0], "Super");
strcpy(adj1[1], "Dreadful");
strcpy(adj1[2], "Frozen");
strcpy(adj1[3], "Scortching");
strcpy(adj1[4], "Epic");
strcpy(adj1[5], "Mini");
strcpy(adj1[6], "Cozy");
strcpy(adj1[7], "Confusing");
strcpy(adj1[8], "The");
strcpy(adj1[9], "Double");
strcpy(adj2[0], "Cold");
strcpy(adj2[1], "Hot");
strcpy(adj2[2], "Happy");
strcpy(adj2[3], "Fairly");
strcpy(adj2[4], "Vaguely");
strcpy(adj2[5], "Haunted");
strcpy(adj2[6], "Trecherous");
strcpy(adj2[7], "Wonderous");
strcpy(adj2[8], "Vast");
strcpy(adj2[9], "Tumbling");
strcpy(adj3[0], "Awesome");
strcpy(adj3[1], "Goofy");
strcpy(adj3[2], "Incredible");
strcpy(adj3[3], "Pleasent");
strcpy(adj3[4], "Explosive");
strcpy(adj3[5], "Crazy");
strcpy(adj3[6], "Special");
strcpy(adj3[7], "Mega");
strcpy(adj3[8], "Expensive");
strcpy(adj3[9], "Dissapointing");
strcpy(city[0], "City");
strcpy(city[1], "Town");
strcpy(city[2], "Village");
strcpy(city[3], "Marshland");
strcpy(city[4], "Forrest");
strcpy(city[5], "Mountain");
strcpy(city[6], "Swamp");
strcpy(city[7], "Island");
strcpy(city[8], "Prarie");
strcpy(city[9], "Beach");
ofp = fopen("AwesomePlaces.txt","w");
srand(time(NULL));
for(i=0; i<k; i++)
{
fprintf(ofp, "%s ", adj1[rand() % 10]);
fprintf(ofp, "%s ", adj2[rand() % 10]);
fprintf(ofp, "%s ", adj3[rand() % 10]);
fprintf(ofp, "%s \n\n", city[rand() % 10]);
}
fclose(ofp);
system("start AwesomePlaces.txt");
return 0;
}
int main(void) {
#include <stdio.h>
putchar ('1');
putchar ('\n');
putchar ('2');
putchar ('\n');
putchar ('3');
putchar ('\n');
putchar ('4');
putchar ('\n');
putchar ('5');
putchar ('\n');
putchar ('6');
putchar ('\n');
putchar ('7');
putchar ('\n');
putchar ('8');
putchar ('\n');
putchar ('9');
putchar ('\n');
putchar ('1');
putchar ('0');
putchar ('\n');
return 0;
}
(define (count)
(define (inner n)
(if (<= n 10)
(display n)))
(inner 1))
(do-ec (: i 1 11) (display i))
10 a = 0
20 a = a + 1
20 print a
40 if a = 10 then goto 60
50 goto 20
60 end
goto considered awesome.>1+::.v
| -,:a<
@<,a._@#-b:::+1
++++++[>++++++++<-]>
>++++++++++>+++++++++[<<+.>.>-]
<<--------.-.>.
(loop for i from 1 to 10 do (print i))
for i in range(1,11): print i
class one210():
def __init__(self):
self.n = 0 #ALWAYS INIT UR VARS
def count(self, by):
self.n += by
def show(self):
print self.n
one2ten = one210()
i = 0
while i < 10:
one2ten.count(1)
one2ten.show()
i += 1
say for 1..10
main = mapM_ (map show [1..10])
def PrintFunction(string):
print string
class Policies:
IncrementPolicy = 1
DecrementPolicy = 2
ProductPolicy = 3
DivisionPolicy = 4
def __init__(self, policy):
self._policy = policy
def doOperation(self, numeric, policyChange = 1):
p = self._policy
if p == self.IncrementPolicy: return numeric + policyChange
if p == self.DecrementPolicy: return numeric - policyChange
if p == self.ProductPolicy: return numeric * policyChange
if p == self.DivisionPolicy: return numeric / policyChange
def startHigh(self):
p = self._policy
if p == self.IncrementPolicy: return False
if p == self.DecrementPolicy: return True
if p == self.ProductPolicy: return False
if p == self.DivisionPolicy: return True
class Counter:
def __init__(self, policy, printFunc = PrintFunction, min = 0, max = 10, step = 1, autoReset = True):
self._min = min
self._max = max
self._step = step
self._policy = Policies(policy)
self._startHigh = self._policy.startHigh()
self._printFunc = printFunc
self._autoReset = autoReset
if self._startHigh: self._cur = max
else: self._cur = min
printFunc("%d" % self._cur)
def process(self):
self._cur = self._policy.doOperation(self._cur, self._step)
printFunc = self._printFunc
printFunc("%d" % self._cur)
if self._startHigh and self._cur <= self._min:
printFunc("Finished iteration")
if self._autoReset:
self._cur = self._max
printFunc("Restarting")
else: return False
elif not self._startHigh and self._cur >= self._max:
printFunc("Finished iteration")
if self._autoReset:
self._cur = self._min
printFunc("Restarting")
else: return False
return True
def TestSuite(oneBased = False):
y = 0
if oneBased: y = 1
x = Counter(Policies.IncrementPolicy, PrintFunction, y, 10, 1, False)
while x.process():
continue
TestSuite()
#lang scheme
(define (count-from start end)
(if (= start end)
(and(newline)end)
(and (newline)
(display start)
(count-from (inc start) end))))
(define (inc x)
(+ x 1))
(count-from 1 100)
and instead of begin 10.times {|x| puts "#{x+1}\n"}
#!/usr/bin/perl
for (1..10) print "$_\n";
#!/usr/bin/perl
for (1..10) { print "$_\n" };
Α ← 0 Β ← 1 α ← 1 β ← 1 « α ≯ 10 α → Λ + → α »
section .text
global _start
_start:
mov esp, 0x31
loop:
mov eax, 4
mov ebx, 1
cmp esp, 0x3a
jnl bmsg
mov dword [msg], esp
mov dword [msg+1], 0xa
mov ecx, msg
mov edx, 2
int 0x80
inc esp
jmp loop
bmsg:
mov dword [msg], 0x31
mov dword [msg+1], 0x30
mov dword [msg+2], 0xa
mov ecx, msg
mov edx, 3
int 0x80
kill:
mov eax, 1
mov ebx, 0
int 0x80
section .bss
msg: resw 3
DOSSEG
.MODEL TINY
.CODE
ORG 100h
s:
pusha
mov al,0
mov ah,0eh
l:
inc al
int 10h
cmp al,0ah
jne l
popa
END s