//p1.
void
PrintZebra(int numS)
{
int i;
printf("-");
for(i = 0; i < numS; i++)
printf("|");
printf("^*");
}
//p2a
void
PrintFamily(int momZebra)
{
int i;
for(i = momZebra; i >=0; i--){
PrintZebra(i);
printf("\n");
}
}
//p2b
void
PrintAverage()
{
double input;
double frac;
double ave;
double sum = 0.0;
int count = 0;
int round = 0;
int i;
printf("Number of stripes:\n");
scanf("%lf", &input);
while(input > 0.0){
sum
+= input;
count
++;
printf("Number
of stripes:\n");
scanf("%lf",
&input);
}
if(count == 0)
return;
ave = sum / count;
round = (int)ave;
frac = ave - round;
if(frac >= 0.5)
round
= round +1;
PrintZebra(round);
}
//p2c
void
MaxHerd()
{
int input;
int sum;
printf("Number of stripes:\n");
scanf("%lf", &input);
if(input
> 50){
printf("Oops!
Too many strips for you.\n");
printf("Total
stripes: 0\n");
return;
}
while(sum <= 50 ){
PrintZebra(input);
printf("\n");
sum
+= input;
printf("Number
of stripes:\n");
scanf("%lf",
&input);
}
printf("Oops! Too many strips for
you.\n");
printf("Total stripes: %d\n",
sum - imput);
}
//p2d
void
HerdRange()
{
int input;
int MAX;
int MIN;
printf("Number of stripes:\n");
scanf("%d", &input);
if(input == -1)
return;
MAX = MIN = input;
while(input != -1){
if(input
> MAX)
MAX
= input;
if(input
< MIN)
MIN
= input;
printf("Number
of stripes:\n");
scanf("%d",
&input);
}
PrintZebra(MAX);
printf("\n");
PrintZebra(MIN);
printf("\n");
printf("range: %d\n", MAX -
MIN);
}
//p2e
void
SquareDance(int numS)
{
int i, j;
for(i = 0; i < numS; i++){
for(j
= 0; j < numS; j++){
PrintZebra(numS);
printf(" ");
}
printf("\n");
}
}
//p2f
void
ZebraAging(int originalS, int year)
{
int i;
int currentS = originalS;
for(i = 0; i < year; i++){
PrintZebra(currentS);
printf("\n");
currentS
= 2 * currentS +1;
}
}