Need help starting program using vector

Please support our C++ advertiser: Intel Parallel Studio Home
Closed Thread

Join Date: Feb 2005
Posts: 8
Reputation: roscioeak@direc is an unknown quantity at this point 
Solved Threads: 0
roscioeak@direc roscioeak@direc is offline Offline
Newbie Poster

Need help starting program using vector

 
0
  #1
Feb 4th, 2005
This is my first post here and so far I have been doing fine in my last C++ class but right now I am stuck. I have to make a program using an array that is initialized dynamically. You have to make a program that will input the rooms of a house;n, and then ask for the user to input the size of each of the rooms until it is done. Then you have to scan the array for the largest room and output its dimensions. I know that you have to do it as a vector so that you can input the data. I just have no idea on how to start this. Please help.
Anthony
Quick reply to this message  
Join Date: Feb 2005
Posts: 30
Reputation: Intel is an unknown quantity at this point 
Solved Threads: 1
Intel Intel is offline Offline
Light Poster

Re: Need help starting program using vector

 
0
  #2
Feb 5th, 2005
HERE ................

#include <iostream>
#include <vector>

int main()
{
using namespace std;
vector< pair<int,double> > Dim;
vector< pair<int,double> >::iterator itr,largest;
int Rooms(0), W, H;

cout << "Rooms of a house :>";
cin >> Rooms;

cout << "Dimensions format : W * H" << endl;
for (int i=1 ; i <= Rooms ; ++i) {
cout << "Room "<< i << " Dimensions:> ";
cin >> W >> H;
Dim.push_back( make_pair(i,W*H) );
};

largest = Dim.begin();
itr = Dim.begin()+1;
while (itr != Dim.end()) {
if ( (*itr).second > (*largest).second)
largest = itr;
++itr;
};

cout << "Room " << (*largest).first << " With Dimensions Size " << (*largest).second
<< " Is The Largest Room" << endl;
return 0;
}
Quick reply to this message  
Join Date: Feb 2005
Posts: 8
Reputation: roscioeak@direc is an unknown quantity at this point 
Solved Threads: 0
roscioeak@direc roscioeak@direc is offline Offline
Newbie Poster

Re: Need help starting program using vector

 
0
  #3
Feb 5th, 2005
Thanks, INTEL
I didn't expect to get that much but now that I see it now I will be able to figure out everything and learn that way.
Anthony
Quick reply to this message  
Join Date: Feb 2005
Posts: 30
Reputation: Intel is an unknown quantity at this point 
Solved Threads: 1
Intel Intel is offline Offline
Light Poster

Re: Need help starting program using vector

 
0
  #4
Feb 6th, 2005
No problem ...
Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Need help starting program using vector

 
0
  #5
Feb 8th, 2005
Intel:

Do not do people's homework for them. Please read this:

http://daniweb.com/techtalkforums/an...nouncementid=2
Alex Cavnar, aka alc6379
Quick reply to this message  
Closed Thread

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC