given a sequence of n elements.increase it by putting after every element the same.for example when you have 1,2,3 the you must increase it by getting 1,1,2,2,3,3.how are i do that using a single array?
kundalish
0
Newbie Poster
Recommended Answers
Jump to Post…VAR a : ARRAY OF INTEGER; x : INTEGER; BEGIN SetLength(a,3); // This dynamically set the size of array to 3. a[0]:=1; a[1]:=2; a[2]:=3; // Now the given values are set. Now to resize. SetLength(a,6);// This resizes the array. x:=3; REPEAT a[x*2-1]:=a[x-1]; a[x*2-2]:=a[x-1]; DEC(x); UNTIL x=0; END.
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.