[ create a new paste ] login | about

Link: http://codepad.org/W8zzVC9j    [ raw code | output | fork ]

PhoeniX888 - C, pasted on Mar 12:
/* Would run forever if you didn't limit it to MAX */
#include <stdio.h>
struct circ_list
{
        char    value[ 3 ];     /* e.g., "st" (incl '\0') */
        struct circ_list        *next;
};
struct circ_list    suffixes[] = {
        "th", & suffixes[ 1 ], /* 0th */
        "st", & suffixes[ 2 ], /* 1st */
        "nd", & suffixes[ 3 ], /* 2nd */
        "rd", & suffixes[ 4 ], /* 3rd */
        "th", & suffixes[ 5 ], /* 4th */
        "th", & suffixes[ 6 ], /* 5th */
        "th", & suffixes[ 7 ], /* 6th */
        "th", & suffixes[ 8 ], /* 7th */
        "th", & suffixes[ 9 ], /* 8th */
        "th", & suffixes[ 0 ], /* 9th */
        };
#define MAX 50
int main()
{
     int i = 0;
     struct circ_list    *p = suffixes;
     while (i <= MAX) 
     {
             printf( "%d%s\n", i, p->value );
             ++i;
             p = p->next;
     }
     return 0;
}


Output:
0th
1st
2nd
3rd
4th
5th
6th
7th
8th
9th
10th
11st
12nd
13rd
14th
15th
16th
17th
18th
19th
20th
21st
22nd
23rd
24th
25th
26th
27th
28th
29th
30th
31st
32nd
33rd
34th
35th
36th
37th
38th
39th
40th
41st
42nd
43rd
44th
45th
46th
47th
48th
49th
50th


Create a new paste based on this one


Comments: