Posted: Tue Sep 14, 2004 7:52 am
At last AC. Thx to all =)
Code: Select all
int lenthofarray; //some how you know it
float halfofarray;
int halfofarrayint;
halfofarray=lenthofarray/2.0;
halfofarrayint= halfofarray; //one kind of type casting
if(halfofarrayint == halfofarray) // then two middle
print -- array[halfofarrayint] and array[halfofarrayint+1];
else
print --array[halfofarrayint];
A1 wrote:your question is not clear!
if you ask about middle of an array
then :
if you talk about prime cut then you have to do little moreCode: Select all
int lenthofarray; //some how you know it float halfofarray; int halfofarrayint; halfofarray=lenthofarray/2.0; halfofarrayint= halfofarray; //one kind of type casting if(halfofarrayint == halfofarray) // then two middle print -- array[halfofarrayint] and array[halfofarrayint+1]; else print --array[halfofarrayint];
Code: Select all
intger leanthofarray;
input: C;
if C*2>=leanthofarray
print every element of array.
else
{
if(leanthofarry is even)
{
start=(leanthofarry-(C*2))/2;
For i=(0+start) To i<(leanthofarray-start)
print array[i];
}
else
{
start=(leanthofarray-((C*2)-1))/2;
For i=(0+start) To i<(leanthofarray-start)
print array[i];
}
}
One problem I see with your solutions is it will not work for input that is larger than 997. Almost certainly the range of input will be more than 997?Ashkankhan wrote:help me WA![]()