Code:
   while (L <= n)
     j = L;
Unless already L > n when this is reached, it is an endless loop. That's because the loop only comprises these two lines and neither L nor n gets changed within the loop. You probably forgot a pair of braces.

Code:
     while (j>=2
     )a[j]<a[j-1];
If this is ever reached (because of the endless loop above), it is an endless loop itself unless j < 2 in the first place for practically the same reasons. Apparently here are some braces missing as well.

This is what I've found so far, but there may very well be more. Your indents are inconsistent and some of the line breaks are simply weird (e.g. considering the ')' in the second code snippet above). Therefore your code is really hard to follow.