Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-

Count to 10

Name: Anonymous 2010-06-17 15:14

Lets see if /prog/ can count to 10 in C. I'll start:

int main(void){

Name: Anonymous 2010-06-17 15:15

int i;

Name: Anonymous 2010-06-17 15:16

for (i = 1; i <= 10; ++i) printf("%d\n", i); return 0; }

Let's not import imageboard ``memes''. We have enough shit to deal with as it is.

Name: Anonymous 2010-06-17 15:16

for(i=0; i < 10; i++)

Name: Anonymous 2010-06-17 15:19

i++

Name: Anonymous 2010-06-17 15:19

>>4
Great, now it's a syntax error. Not that it would have gone far, with >>1 forgetting to #include <stdio.h> anyway.

Name: Anonymous 2010-06-17 15:20

#include <stdmeme.h>

Name: Anonymous 2010-06-17 15:20

>>4-5
C++ users haven't read their K&R.

Name: Anonymous 2010-06-17 15:21

return(0);

Name: Anonymous 2010-06-17 15:22

>>9
Good god. If that's how you write C, you need to stop.

Name: Anonymous 2010-06-17 15:24

strcpy(i[3], "Marshland");

Name: Anonymous 2010-06-17 15:25

>>11
THAT IS NOT A STRING!

Name: Anonymous 2010-06-17 15:25

>>1-12

What is wrong with you /prog/? I thought you were better than this.

Name: Anonymous 2010-06-17 15:26

>>10
Valid C code. I jus tried it.

Name: Anonymous 2010-06-17 15:27

>>14
The fact that it compiles doesn't make it valid.

Name: Anonymous 2010-06-17 15:28

>>11
What are you doing? Go sit in the corner.

Name: Anonymous 2010-06-17 15:29

Requesting SAGETANK. May we never speak of this again.

Name: Anonymous 2010-06-17 15:31

I hope this is the work of clever (albeit asinine) trolls.

Name: Anonymous 2010-06-17 15:43

>>18
You idealists always want to see the best in people.

Name: Anonymous 2010-06-17 16:29

>>6
Can't you just stick an #include anywhere? I just started learning C yesterday.

#include <stdio.h>

Fixed?

Name: Anonymous 2010-06-17 16:41

>>20
It's too late! The preprocessor just drops in the .h file where the #include statement is. All the calls inside main will have been to functions that have as of yet undeclared.

Name: Anonymous 2010-06-17 16:44

for loops considered harmful

Name: Anonymous 2010-06-17 16:50

>>22
That's poor grammar. Did you mean ``four loops considered harmful''?

Name: Anonymous 2010-06-17 16:51

>>22
nope

Name: Anonymous 2010-06-17 16:53

>>1-1000,,,,,,,,,,,,
Valid idiot code.

Name: Anonymous 2010-06-17 16:59

>>22
Fun fact for(;;) is faster than while(1).

Name: Anonymous 2010-06-17 17:00

>>21
Oh dear.

Name: Anonymous 2010-06-17 17:06

[borat]Theis thread iz vary niiice![/borat]

Name: Anonymous 2010-06-17 17:08

>>28
Go play in traffic.

Name: Anonymous 2010-06-17 17:09

[b][i][o][u]

Name: Anonymous 2010-06-17 17:10

#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;
}

Name: Anonymous 2010-06-17 17:11

>>20 here, am I doing this right?
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;
}

Name: Anonymous 2010-06-17 17:16

while(int i++)
{
printf(i);
}

Name: Anonymous 2010-06-17 17:16

>>33
NOW THATS THE TICKET!     

Name: Anonymous 2010-06-17 17:21

>>33
Go back to using Scheme as a masturbation aid.

Name: Anonymous 2010-06-17 17:23

>>33
Looks like you accidentally the while loop.

Name: Anonymous 2010-06-17 17:24

>>35
Because when you see terrible (!) code, your first impulse is to think that it must be someone who knows Lisp? I think you have a few things backwards.

Name: Anonymous 2010-06-17 18:49

>>37
It is a very widely-known fact that using Lisp for extended periods of time leads to irreversible brain damage.

Name: Anonymous 2010-06-17 19:14

irreversible brain damage
Enlightenment is not (necessarily) brain damage

Name: Anonymous 2010-06-17 19:36


(define (count)
  (define (inner n)
    (if (<= n 10)
        (display n)))
   (inner 1))

Name: Anonymous 2010-06-17 20:16

(do-ec (: i 1 11) (display i))

Name: Anonymous 2010-06-17 20:34

>>39
True, too bad you arn't the Dalai Lama.

Name: Anonymous 2010-06-17 20:42

lisp code considered harmful

Name: Anonymous 2010-06-17 21:14

>>40
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

etc.

Name: Anonymous 2010-06-17 21:21


10 a = 0
20 a = a + 1
20 print a
40 if a = 10 then goto 60
50 goto 20
60 end

Name: Anonymous 2010-06-17 21:43

>>45
goto considered harmful

Name: Anonymous 2010-06-17 22:52

>>46
goto considered awesome.
the advice against it is like a giant trolling campaign to ensure that this brilliant feature is used only by those who can properly use it (and can think critically about complex ideas)
only EXPERT ENTERPRISE SOFTWARE ENGINEERS can use it properly, so don't even try.

Name: Anonymous 2010-06-17 22:56

>>46
10 a = 0
20 a = a + 1
30 print a
40 if a = 10 then gosub 60
50 gosub 20
60 end

Name: Anonymous 2010-06-17 23:35

>1+::.v
| -,:a<
@

cough

Name: Anonymous 2010-06-17 23:46

<,a._@#-b:::+1
How about a one-liner?

Name: Anonymous 2010-06-17 23:49

++++++[>++++++++<-]>
+.>++++++++++.<
+.>.<
+.>.<
+.>.<
+.>.<
+.>.<
+.>.<
+.>.<
+.>.<
--------.-.>.

Name: Anonymous 2010-06-17 23:54

>>51
You could easily eliminate all but one of those +.>.<s. And you could even use code tags!

Name: Anonymous 2010-06-17 23:59

>>49-50
I forgot to mention these are both Befunge-98. Befunge-93 doesn't know what a and b are.

Name: Anonymous 2010-06-18 0:12

>>52
For code that I wrote, posted, and then checked to see if it worked, I am happy. Does this make you slightly less annoyed:

++++++[>++++++++<-]>
>++++++++++>+++++++++[<<+.>.>-]
<<--------.-.>.

Name: Anonymous 2010-06-18 0:40

(loop for i from 1 to 10 do (print i))

Name: Anonymous 2010-06-18 0:47

for i in range(1,11): print i

Name: Anonymous 2010-06-18 1:01


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

Name: Anonymous 2010-06-18 1:24

say for 1..10

Name: Anonymous 2010-06-18 1:28

main = mapM_ (map show [1..10])

Name: Anonymous 2010-06-18 1:34

>>59
main = mapM_ print [1..10]

Name: Anonymous 2010-06-18 1:57

>>57
Not enterprise enough. I will give examples for both 0-based and 1-based.

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()

Name: Anonymous 2010-06-18 2:32

[code]
#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 10)
[code]

Name: Anonymous 2010-06-18 2:32


#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)

Name: Anonymous 2010-06-18 16:13

>>31
This program is actually pretty enjoyable. You all should compile it and have a laugh.

Name: Anonymous 2010-06-18 16:18

>>64
It doesn't even compile on a ANSI-conforming compiler. It mixes C99 with C89.

Name: Anonymous 2010-06-18 16:22

using and instead of begin
W-D

Name: Anonymous 2010-06-18 16:25

10.times {|x| puts "#{x+1}\n"}

Name: Anonymous 2010-06-18 17:38

#!/usr/bin/perl
for (1..10) print "$_\n";

Name: Anonymous 2010-06-18 17:46

>>68
syntax error at line 2, near ") print"
Execution aborted due to compilation errors.

Name: Anonymous 2010-06-18 17:57

>>69
had shell programming on my mind. forgot the braces

#!/usr/bin/perl
for (1..10) { print "$_\n" };

Name: Anonymous 2010-06-18 17:59

>>68
Perl does not work that way.

print map "$_\n",1..10

Name: Anonymous 2010-06-18 18:06

Perl, so elegant and beautiful.

Name: Anonymous 2010-06-18 18:29

>>54
I didn't say I was annoyed, but seriously: do use code tags.

The other was just a tip.

Name: Anonymous 2010-06-18 18:37


#include <stdio.h>

void main(){
  int i = 0;
  while (i < 10)
    printf("%d\n", ++i);
}


@ >>26 lol

Name: Anonymous 2010-06-18 18:48

Α ← 0 Β ← 1 α ← 1 β ← 1 « α ≯ 10 α → Λ + → α »

Name: Anonymous 2010-06-18 18:56

>>75
Once again the syntax highlighter fucks up royally.

Name: Anonymous 2010-06-18 19:02

>>76
The syntax highlighter is doing it's job perfectly. It's one of the few parts of shiichan that actually works 100% all the time.

Name: Anonymous 2010-06-18 19:28

>>77
I don't think nothing but purple and green is considered acceptable highlighting in any language, even esoteric ones.

Name: Anonymous 2010-06-18 20:10

>>78
That's cool and all, but colorblindness disqualifies you from getting to make aesthetic calls of that sort.

Name: Anonymous 2010-06-18 21:51

>>79
I know it's hard to imagine as a girl, but most men are colorblind. You can't just disqualify them from putting a value on sensory perception like that.
But fine, brown ochre and dark cyan, if you prefer. It's still hideous.

Name: Anonymous 2010-06-18 22:54

>>80
Note: it's doing it's job exactly as intended.

Name: Anonymous 2010-06-18 23:15

>>81
I don't know what you think syntax highlighting is for, but most people would say it's to make code easier to read. It fails miserably.

Name: Anonymous 2010-06-19 0:02

>>82
It's doing its job exactly as intended.

Name: Anonymous 2010-06-19 1:27

>>83
If you're expecting a set-up so you can deliver some kind of punchline, you aren't going to get it. Dipshit.

Name: Anonymous 2010-06-19 12:35

print 1
print 2
print 3
print 4
print 5
print 6
print 7
print 8
print 9
print 10

Name: Anonymous 2010-06-19 12:49

>>84
PUNCHLINE MY ANUS

Name: Anonymous 2010-06-19 13:14

>>86
Get the fuck out.

Name: Anonymous 2010-06-19 13:32

>>84,86-87
Hahahahaha.

Name: Anonymous 2010-06-19 14:26

>>87
SEFYIE1ZIEFOVVMK

Name: Anonymous 2010-06-19 14:34

>>89
Base64. How clever.

Name: Anonymous 2010-06-19 17:44

>>90
1c 05 cc 60 03 54

Name: Anonymous 2010-06-19 17:46

>>91,90
Sorry, I meant 04 04 84 eb 83 18 00 d5 12

Name: Anonymous 2010-06-21 5:19

potato

Name: Anonymous 2010-06-24 11:02

2000 hrs in mspaint nano


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

Name: Anonymous 2010-06-24 11:18

>>94

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

Name: Anonymous 2010-06-24 11:19

>>95
Oh, you probably want ASCII, go for mov al,30 instead then.

Name: FrozenVoid 2010-06-24 12:34

#include "stdio.h"
#define br break
main(int argc, char**argv, char**envp){
switch(argc){
case 1:;for(argc=0;argc<10;printf("%d\n",++argc));br;
case 2:;printf("Have you read your %s today?",argv[1]);br;
case 3:;printf("%s is the new %s",argv[1],argv[2]);br;
default:;argc=0;puts("Secret environment data:\n\n\n");
for(;envp[argc];printf("\t%s\n", envp[argc++]));br;
}}




__________________
Orbis terrarum delenda est

Name: Anonymous 2010-06-24 12:40

I like your useless semicolons. I thought your main programming goal was brevity, though.

Name: FrozenVoid 2010-06-24 12:50

>>98 semicolons are great when i type it in one big line.
The post was formatted for /prog/ viewing pleasure.

C:\Program Files\tcc>test Facebook Compuserve
Facebook is the new Compuserve
C:\Program Files\tcc>test Slashdot
Have you read your Slashdot today?


__________________
Orbis terrarum delenda est

Name: Anonymous 2010-06-24 12:53

>>97
Why would you do that to the poor argc? :-(

Name: Anonymous 2010-06-24 12:53

100 get

Name: Anonymous 2010-06-24 12:54

FUCK

Name: Anonymous 2010-06-24 15:18

>>31
Scortching

also
if( a > b )
  return( (0) ) ;

Name: Anonymous 2010-06-24 16:27

>>2

Listen here, Fuckface.

Name: Anonymous 2010-06-24 17:02

>>104
Fuck here, Listenface.

Name: Anonymous 2010-06-24 17:20

FACE HERE, FUCKLISTEN[/u]

Name: Anonymous 2010-06-24 17:21

FUCKING BBCODE!!!!

Name: Anonymous 2010-06-24 17:35

[sub][sub][o]CODING BBFUCK[/u][/sub][/sub]

Name: Anonymous 2010-06-24 17:36

oh lawdy epic failure

CODING BBFUCK

Don't change these.
Name: Email:
Entire Thread Thread List