OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [stdalone/] [bottles/] [main.c] - Blame information for rev 291

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 213 hellwig
/*
2
 * main.c -- main program
3
 */
4
 
5
 
6
#include "types.h"
7
#include "stdarg.h"
8
#include "iolib.h"
9
 
10
 
11
#define MAX_BEER        99
12
 
13
 
14
char *t = "bottle";
15
char *b = "of beer";
16
char *w = "on the wall";
17
char *m = "more";
18
 
19
 
20
void beer(int n) {
21
  char *s;
22
 
23
  s = (n == 1 ? "" : "s");
24
  printf("%d %s%s %s %s, ", n, t, s, b, w);
25
  printf("%d %s%s %s.\n", n, t, s, b);
26
  n--;
27
  s = (n == 1 ? "" : "s");
28
  printf("Take one down and pass it around, ");
29
  if (n == 0) {
30
    printf("no %s", m);
31
  } else {
32
    printf("%d", n);
33
  }
34
  printf(" %s%s %s %s.\n\n", t, s, b, w);
35
}
36
 
37
 
38
void main(void) {
39
  int i;
40
 
41
  for (i = MAX_BEER; i > 0; i--) {
42
    beer(i);
43
  }
44
  printf("No %s %ss %s %s, ", m, t, b, w);
45
  printf("no %s %ss %s.\n", m, t, b);
46
  printf("Go to the store and buy some %s, ", m);
47
  printf("%d %ss %s %s.\n", MAX_BEER, t, b, w);
48
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.