第十三届全国信息学奥林匹克竞赛各省复赛C语言试题答案。

# include & ltstdio.h & gt

# include & ltstring.h & gt

#定义LEN 200000

int a[LEN],temp,mid

Intsort (int * a,int low,int high)//一趟快车。

{

mid = a[低];

while(low & lt;高)

{

while(low & lt;高& amp& amp一个[高]>=中)高-;

temp = a[低];a[低]= a[高];a[高]=温度;

while(low & lt;高& amp& amp一个[高]& lt;=mid)低++;

temp = a[低];a[低]= a[高];a[高]=温度;

}

返低;

}

Void快速排序(int * a,int low,int high)//快速递归。

{

//int mid;

if(低& lt高)

{

mid=sort(a,低,高);

快速排序(a,低,中1);

快速排序(a,中+1,高);

}

}

int main()

{

FILE * fp

int i,j,n,sum

fp=fopen("count.in "," r ");

fscanf(fp," %d ",& ampn);

for(I = 0;我& ltn;i++)

fscanf(fp," %d ",& ampa[I]);

fclose(FP);

快速排序(a,0,n-1);//调用快速队列

fp=fopen("count.out "," w ");

for(I = sum = 0;我& ltn;I++) //统计不同数字的个数。

if (a[i+1]!= a[I])sum++;

for (n=1,i=0,j = 0;我& lt总和;I++,j++) //统计并输出。

{

while(a[j+1]= = a[j]){ n++;j++;}

fprintf(fp," %d %d\n ",a[j],n);

printf("%d %d\n ",a[j],n);

n = 1;

}

fclose(FP);

//返回1;

系统(“暂停”);

}

努力吧,加油!