帮忙给每一行都加上注释 谢谢
第一个程序
#define X 10
#define Y 30
#define N 20
int A[N]={2,5,15,30,1,40,17,50,9,21,32,8,41,22,49,31,33,18,80,5};
#include<stdio.h>
void del(int *A, int *n, int x, int y)
{
int i,j;
for(i=j=0; i<*n; i++)
if(A[i]>y||A[i]<x)
A[j++]=A[i];
*n=j;
}
void output(int *A, int n)
{
int i;
printf("\n数组有%d个元素:\n",n);
for(i=0; i<n; i++){
printf("%7d",A[i]);
if((i+1)%10==0)
printf("\n");
}
printf("\n");
}
void main()
{
int n;
n=N;
output(A,n);
del(A,&n,X,Y);
output(A,n);
}
第二个程序
#include<stdio.h>
struct LinearList
{
int *list;
int size;
int MAXSIZE;
};
main()
{
int list1[15]={2,5,7,8,10,14,19,22,25,30};
int list2[15]={3,5,8,9,11,18,22,28,30,32,35};
int list3[30];
struct LinearList L1={list1,10,15};
struct LinearList L2={list2,11,15};
struct LinearList L3={list3,0,30};
int i,j,k;
for(i=j=k=0; k<L3.MAXSIZE&&i<L1.size&&j<L2.size; k++)
{
if(L1.list[i]>L2.list[j])
L3.list[k]=L2.list[j++];
else if(L1.list[i]==L2.list[j])
{
L3.list[k]=L1.list[i++];
j++;
}
else
L3.list[k]=L1.list[i++];
}
while(k<L3.MAXSIZE&&i<L1.size)
L3.list[k++]=L1.list[i++];
while(k<L3.MAXSIZE&&j<L2.size)
L3.list[k++]=L2.list[j++];
L3.size=k;
printf("合并后的数组长度是[%d]\n各元素如下:\n",L3.size);
for(k=0;k<L3.size;k++)
printf("%4d",L3.list[k]);
printf("\n");
return 0;
}