展开全部
#include <stdio.h>
int main()
{
FILE *fp;
float a[10];
int i,j;
float t;
fp = fopen("C:\\score.txt", "r");
for(i = 0; i < 10; i ++)
{
fscanf(fp,"%f",&t);
for(j = i-1; j>=0; j --)
if(a[j]<=t)break;
else a[j+1]=a[j];
a[j+1]=t;
}
fclose(fp);
fp = fopen("in.txt", "w");
for(i = 0; i < 10; i ++)
fprintf(fp, "%f ", a[i]);
fclose(fp);
return 0;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <stdio.h>
void main()
{
FILE* fp;
int i,j,temp,a[10];
fp = fopen( "C:\\score.txt", "r" );
for (i=0;i<10;i++)
fscanf(fp,"%d",&a[i]);
fclose(fp);
for(j=0;j<=9;j++)
{
for (i=0;i<10-j;i++)
if (a[i]>a[i+1])
{
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
}
fp = fopen( "C:\\score.txt", "w" );
for (i=0;i<10;i++)
fprintf(fp,"%d ",a[i]);
fclose(fp);
}
void main()
{
FILE* fp;
int i,j,temp,a[10];
fp = fopen( "C:\\score.txt", "r" );
for (i=0;i<10;i++)
fscanf(fp,"%d",&a[i]);
fclose(fp);
for(j=0;j<=9;j++)
{
for (i=0;i<10-j;i++)
if (a[i]>a[i+1])
{
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
}
fp = fopen( "C:\\score.txt", "w" );
for (i=0;i<10;i++)
fprintf(fp,"%d ",a[i]);
fclose(fp);
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询