1个回答
展开全部
已经回答过你了,你也采纳别人了。好好的代码,怎么?在你那里就不行?设你的文件名是123.txt。
#include "stdafx.h"//vc++6.0加上这一行.//
#include "stdio.h"
#include "stdlib.h"
void main(void){
FILE *fp;
double a[1000],x;
int i=0,j;
if((fp=fopen("123.txt","r"))==NULL){
printf("Open the file failure...\n");
exit(0);
}
fscanf(fp,"%lf %lf %lf %lf %lf %lf %lf",&x,&x,a+i,&x,&x,&x,&x);
for(i=1;feof(fp)==0;i++)
fscanf(fp,"%lf %lf %lf %lf %lf %lf %lf",&x,&x,a+i,&x,&x,&x,&x);
for(j=0;j<i;printf("%.14e ",a[i++]));
printf("\n");
}
#include "stdafx.h"//vc++6.0加上这一行.//
#include "stdio.h"
#include "stdlib.h"
void main(void){
FILE *fp;
double a[1000],x;
int i=0,j;
if((fp=fopen("123.txt","r"))==NULL){
printf("Open the file failure...\n");
exit(0);
}
fscanf(fp,"%lf %lf %lf %lf %lf %lf %lf",&x,&x,a+i,&x,&x,&x,&x);
for(i=1;feof(fp)==0;i++)
fscanf(fp,"%lf %lf %lf %lf %lf %lf %lf",&x,&x,a+i,&x,&x,&x,&x);
for(j=0;j<i;printf("%.14e ",a[i++]));
printf("\n");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询