Last change
on this file since 129 was
81,
checked in by rosiere, 17 years ago
|
- Finish Environment (and test)
- Continue predictor_unit
- Add external tools
- svn keyword "Id" set
|
-
Property svn:keywords set to
Id
|
File size:
803 bytes
|
Line | |
---|
1 | /* |
---|
2 | * 99 bottles of beer in ansi c |
---|
3 | * |
---|
4 | * by Bill Wein: bearheart@bearnet.com |
---|
5 | * |
---|
6 | */ |
---|
7 | #include "bottles.h" |
---|
8 | #include <stdio.h> |
---|
9 | #include <stdlib.h> |
---|
10 | #include <string.h> |
---|
11 | |
---|
12 | void chug(int beers); |
---|
13 | |
---|
14 | void bottles(int nb_beers) |
---|
15 | { |
---|
16 | register int beers; |
---|
17 | |
---|
18 | for(beers = nb_beers; beers; chug(beers--)) |
---|
19 | puts(""); |
---|
20 | |
---|
21 | puts("\nTime to buy more beer!\n"); |
---|
22 | } |
---|
23 | |
---|
24 | void chug(register int beers) |
---|
25 | { |
---|
26 | char howmany[8], *s; |
---|
27 | |
---|
28 | s = beers != 1 ? "s" : ""; |
---|
29 | printf("%d bottle%s of beer on the wall,\n", beers, s); |
---|
30 | printf("%d bottle%s of beeeeer . . . ,\n", beers, s); |
---|
31 | printf("Take one down, pass it around,\n"); |
---|
32 | |
---|
33 | if(--beers) sprintf(howmany, "%d", beers); else strcpy(howmany, "No more"); |
---|
34 | s = beers != 1 ? "s" : ""; |
---|
35 | |
---|
36 | printf("%s bottle%s of beer on the wall.\n", howmany, s); |
---|
37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.