Commit 8072b1eb authored by Artak Yenokyan's avatar Artak Yenokyan

Merge branch 'exe_05_28' into 'master'

Exercise_05_28, Version1 See merge request bpcarm/trainings2017!1246
parents 7f246a91 0482f9b2
Pipeline #23042805 failed with stage
in 1 minute 53 seconds
progname = exercise_05_28
CC = g++
CFLAGS = -Wall -Wextra -Werror -g3
$(progname): $(progname).o | .gitignore
$(CC) $(CFLAGS) $^ -o $@
%.ii: %.cpp
$(CC) -E $(CFLAGS) $< -o $@
%.s: %.ii
$(CC) -S $(CFLAGS) $< -o $@
%.o: %.s
$(CC) -c $(CFLAGS) $< -o $@
.gitignore:
echo $(progname) > $@
clean:
rm -f *.ii *.s *.o *.out $(progname) .gitignore
test: $(progname)
./$(progname) > $@.out
diff $@.out $@.expected && echo PASSED || echo FAILED
.PRECIOUS: $(progname).ii $(progname).s
.SECONDARY: $(progname).ii $(progname).s
#include <iostream>
int
main()
{
for (int day = 1; day <= 12; ++day) {
std::cout << "On the ";
switch (day) {
case 1: std::cout << "first"; break;
case 2: std::cout << "second"; break;
case 3: std::cout << "third"; break;
case 4: std::cout << "fourth"; break;
case 5: std::cout << "fifth"; break;
case 6: std::cout << "sixth"; break;
case 7: std::cout << "seventh"; break;
case 8: std::cout << "eighth"; break;
case 9: std::cout << "ninth"; break;
case 10: std::cout << "tenth"; break;
case 11: std::cout << "eleventh"; break;
case 12: std::cout << "twelfth"; break;
}
std::cout << " day of Christmas" << std::endl
<< "my true love sent to me: " << std::endl;
switch (day) {
case 12: std::cout << "12 Drummers Drumming" << std::endl;
case 11: std::cout << "Eleven Pipers Piping" << std::endl;
case 10: std::cout << "Ten Lords a Leaping" << std::endl;
case 9: std::cout << "Nine Ladies Dancing" << std::endl;
case 8: std::cout << "Eight Maids a Milking" << std::endl;
case 7: std::cout << "Seven Swans a Swimming" << std::endl;
case 6: std::cout << "Six Geese a Laying" << std::endl;
case 5: std::cout << "Five Golden Rings" << std::endl;
case 4: std::cout << "Four Calling Birds" << std::endl;
case 3: std::cout << "Three French Hens" << std::endl;
case 2: std::cout << "Two Turtle Doves and" << std::endl;
case 1: std::cout << "A Partridge in a Pear Tree" << std::endl;
}
std::cout << std::endl;
}
return 0;
}
On the first day of Christmas
my true love sent to me:
A Partridge in a Pear Tree
On the second day of Christmas
my true love sent to me:
Two Turtle Doves and
A Partridge in a Pear Tree
On the third day of Christmas
my true love sent to me:
Three French Hens
Two Turtle Doves and
A Partridge in a Pear Tree
On the fourth day of Christmas
my true love sent to me:
Four Calling Birds
Three French Hens
Two Turtle Doves and
A Partridge in a Pear Tree
On the fifth day of Christmas
my true love sent to me:
Five Golden Rings
Four Calling Birds
Three French Hens
Two Turtle Doves and
A Partridge in a Pear Tree
On the sixth day of Christmas
my true love sent to me:
Six Geese a Laying
Five Golden Rings
Four Calling Birds
Three French Hens
Two Turtle Doves and
A Partridge in a Pear Tree
On the seventh day of Christmas
my true love sent to me:
Seven Swans a Swimming
Six Geese a Laying
Five Golden Rings
Four Calling Birds
Three French Hens
Two Turtle Doves and
A Partridge in a Pear Tree
On the eighth day of Christmas
my true love sent to me:
Eight Maids a Milking
Seven Swans a Swimming
Six Geese a Laying
Five Golden Rings
Four Calling Birds
Three French Hens
Two Turtle Doves and
A Partridge in a Pear Tree
On the ninth day of Christmas
my true love sent to me:
Nine Ladies Dancing
Eight Maids a Milking
Seven Swans a Swimming
Six Geese a Laying
Five Golden Rings
Four Calling Birds
Three French Hens
Two Turtle Doves and
A Partridge in a Pear Tree
On the tenth day of Christmas
my true love sent to me:
Ten Lords a Leaping
Nine Ladies Dancing
Eight Maids a Milking
Seven Swans a Swimming
Six Geese a Laying
Five Golden Rings
Four Calling Birds
Three French Hens
Two Turtle Doves and
A Partridge in a Pear Tree
On the eleventh day of Christmas
my true love sent to me:
Eleven Pipers Piping
Ten Lords a Leaping
Nine Ladies Dancing
Eight Maids a Milking
Seven Swans a Swimming
Six Geese a Laying
Five Golden Rings
Four Calling Birds
Three French Hens
Two Turtle Doves and
A Partridge in a Pear Tree
On the twelfth day of Christmas
my true love sent to me:
12 Drummers Drumming
Eleven Pipers Piping
Ten Lords a Leaping
Nine Ladies Dancing
Eight Maids a Milking
Seven Swans a Swimming
Six Geese a Laying
Five Golden Rings
Four Calling Birds
Three French Hens
Two Turtle Doves and
A Partridge in a Pear Tree
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment