Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // for lab - week of 11/14/2011
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <string>
- using namespace std;
- struct person_Type
- {
- string firstname;
- double height; // height in inches
- double weight; // weight in pounds
- };
- typedef person_Type infoType ; // typedef on page 425 in Malik
- struct nodeType
- {
- infoType info;
- nodeType *link;
- };
- // Function Prototypes
- void print_to_Screen(nodeType *list);
- int main ()
- {
- nodeType *first;
- first = new nodeType;
- first->info.firstname = "Mario";
- first->info.weight = 95.0;
- first ->info.height = 50.0;
- first->link = NULL;
- print_to_Screen ( first);
- cout << "\n\n";
- system ("pause");
- return 0;
- }
- /*
- print displays the members of each element of the
- linked list of structures of type nodeType; the formal parameter
- list points to the first node in the list.
- info is a struct with height and weight
- */
- void print_to_Screen(nodeType *list)
- {
- cout << fixed;
- cout << setprecision(1);
- cout << "The list of heights and weights\n\n"
- << setw(15) <<left<< "name" << setw(15)<<left <<"height(inches)" << left<<setw(20)<< "weight(pounds)"
- << endl <<endl<<endl;
- nodeType *current;
- current = list;
- while (current != NULL)
- {
- cout << setw(15) <<left<< (current->info.firstname);
- cout <<setw(15)<<left << (current->info.height);
- cout << setw(20)<<left << (current->info.weight);
- current = current->link;
- cout << endl;
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement