数据结构排序编程求解
发布网友
发布时间:2024-03-19 03:37
我来回答
共1个回答
热心网友
时间:2024-04-02 16:06
#inclde<stdio.h>
#incude<stdlib.h>
int main(int argc,char *argv[])
{
FILE *fpr,*fpw;
int ch;
int arr[100];
if(argc != 2)
{
printf("missing file name:\n");
exit(0);
}
if((fpr = fopen(argv[1],"r+b"))==NULL)
{
printf("cannot open the file:\n");
}
if((fpw = fopen(argv[1],"r+b"))==NULL)
{
printf("cannot open the file:\n");
}
i=0;
while((ch = fget(fpr)) != EOF)
{
arr[i] = ch;
}
//在这儿将arr[i]数组排序你应该可以吧;
i=0;
while((ch = fget(fpr)) != EOF)
{
fput((arr[i]),fpw);
i++;
}
fclose(fpr);
fclose(fpw);
}