Advertisement
blainebrown

Untitled

Nov 15th, 2011
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. // for lab - week of 11/14/2011
  2.  
  3. #include <iostream>
  4. #include <fstream>
  5. #include <iomanip>
  6. #include <string>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. struct person_Type
  12. {
  13. string firstname;
  14. double height; // height in inches
  15. double weight; // weight in pounds
  16. };
  17.  
  18. typedef person_Type infoType ; // typedef on page 425 in Malik
  19.  
  20. struct nodeType
  21. {
  22. infoType info;
  23. nodeType *link;
  24. };
  25.  
  26. // Function Prototypes
  27. void print_to_Screen(nodeType *list);
  28.  
  29. int main ()
  30. {
  31. nodeType *first;
  32.  
  33. first = new nodeType;
  34. first->info.firstname = "Mario";
  35. first->info.weight = 95.0;
  36. first ->info.height = 50.0;
  37. first->link = NULL;
  38.  
  39. print_to_Screen ( first);
  40.  
  41.  
  42. cout << "\n\n";
  43. system ("pause");
  44. return 0;
  45. }
  46.  
  47. /*
  48. print displays the members of each element of the
  49. linked list of structures of type nodeType; the formal parameter
  50. list points to the first node in the list.
  51. info is a struct with height and weight
  52. */
  53.  
  54. void print_to_Screen(nodeType *list)
  55. {
  56. cout << fixed;
  57. cout << setprecision(1);
  58.  
  59. cout << "The list of heights and weights\n\n"
  60. << setw(15) <<left<< "name" << setw(15)<<left <<"height(inches)" << left<<setw(20)<< "weight(pounds)"
  61. << endl <<endl<<endl;
  62.  
  63. nodeType *current;
  64. current = list;
  65.  
  66. while (current != NULL)
  67. {
  68. cout << setw(15) <<left<< (current->info.firstname);
  69.  
  70. cout <<setw(15)<<left << (current->info.height);
  71. cout << setw(20)<<left << (current->info.weight);
  72.  
  73. current = current->link;
  74. cout << endl;
  75. }
  76. cout << endl;
  77. }
  78.  
  79.  
  80.  
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement