Oct 9, 2012 at 4:18pm
Hi can u help me to write this program please...
Q: Write a program which will allow the user to define the size of array and allow him to prompt the number.Display the array in ascending order.
thx
Oct 9, 2012 at 4:21pm
1 2 3 4
|
int* a;
a = new int[size];
for (i = 0 to size) cin >> a[i];
std::sort(a, a+size);
|
Last edited on Oct 9, 2012 at 4:22pm
Oct 9, 2012 at 4:23pm
what about
int a[n]
n* for unknown size of array?
Oct 9, 2012 at 4:37pm
That's not legal unless n is a constant. (And, obviously the size of the array would then be known.)
Using std::vector would be my choice.
Oct 9, 2012 at 4:40pm
ok thanks.... now i understand it better