1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <iostream>
using namespace std;
struct pet{
string name;
int age;
bool isNeutered;
};
void printPets(pet* Pets, int i)
{
cout << Pets[i].name << " ";
cout << Pets[i].age << " ";
switch (Pets[i].isNeutered)
{
case true:
cout << "Yes\n";
break;
case false:
cout << "No\n";
break;
}
}
int main(){
pet Pets[5] = {{"Fido", 7, true}, {"Puppy", 1, false},{"Kitty", 1, false}, {"Brutus", 11, true}, {"Bilbo", 15, true} };
printPets(Pets, 2);
cout << "Name Age Neutered" << endl << "----------------------------" << endl;
for (int i=0; i < 5; i++){
printPets(Pets, i);
}
}
|