c语言 行计数程序

来源:百度知道 编辑:UC知道 时间:2024/06/05 15:22:05
请写出详细的代码,并能够成功运行

void CountSort(int* pData,int Count)
{
int temp[100];
int s[100];
int r[100];
for(int q=0;q<100;q++)//初始化
{
temp[q]=0;
s[q]=0;
r[q]=0;
}
for(q=0;q<100;q++)
{
for(int i=0;i<100;i++)
{
if(q==pData[i])
{
temp[q]++;
}
}
s[q]=temp[q];
}
for(int j=1;j<100;j++)
{
temp[j]=temp[j]+temp[j-1];//此时temp[j]里面存放的是小于或等于j的个数
}
for(j=99;j>=0;j--)
{
if(s[pData[j]]>0)
{
r[temp[pData[j]]]=pData[j];
temp[pData[j]]--;
}
r[temp[pData[j]]]=pData[j];
}

}

#include <stdio.h>
main()
{FILE *fp;
int line=0;
clrscr();
if((fp=fopen("你文件的路径","r"))==NULL)
{printf("Can't open file!\n");
exit(0);}
while(!feof(fp))
if(fgetc(fp)=='\n') line++;
fclose(fp);
printf("%d&quo