Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Use the new operator to dynamically allocate an integer array of length n
Use the new operator to dynamically allocate an integer array of length n

#include

#include

using?namespace?std;

int?main()? {

int?n;

cin?>>?n;

int?*p?=?new?int[n];

for?(int?i?=?0;?i?

p[i]?=?rand()?%?6?+?1 ;

for?(int?i?=?0;?i?

for?(int?j?=?i;? j?

if?(p[j]?<=?p[i])

swap(p[i],?p[j ]);

cout?<

}

delete[]?p;

return?0;

}

OK, you can also use other methods to sort that section.