-
July 17th, 2009, 11:41 AM
#1
need help!!!^^
how to use array Allow the user to specify the number of inputs to be used (up to a maximum number)??
is it something like this??
const int SIZE = 30;
int a[SIZE];
int i,n,h;
cout<<"Enter the number of Reistor except Rf:";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"Enter the resistance of R"<<a[i];
cin>>h;
}
return 0;
}
-
July 17th, 2009, 11:56 AM
#2
Re: need help!!!^^
#include <vector> and use a std::vector<int>.
-
July 17th, 2009, 01:10 PM
#3
Re: need help!!!^^
If you have a known maximum number, then there's no need to get vectors involved. Simply store that maximum in a variable somewhere. The fact that the array is bigger than that doesn't matter---you simply ignore any slots in it beyond that value.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|