tcdone3.c

来自「按照既定的步长」· C语言 代码 · 共 52 行

C
52
字号
#include"math.h"
#include"stdio.h"
#include<stdio.h>
main()
{    
        FILE *fpi;
        FILE *fpo;                      
     
        double c1,c2,c3;            
    
        double rr[7];
        double pp[5]; 
        double tt[5];               
                           
        int i,j;
     
        printf("Please enter the step: ");
        scanf("%lf",&c3);      

      if((fpi=fopen("E:\\My paper\\datepick\\r01.txt","r"))==NULL) 
                                              /*请在“”内输入要处理的文件*/
         {  printf("Can not open this file!");
            exit(0); } 
      fpo=fopen("E:\\My paper\\datepick\\r2.txt","a");           
                                              /*请在“”内输入存放结果的文件*/         
          
        
      while(fscanf(fpi,"%lf%lf%lf%lf%lf%lf%lf",&rr[0],&rr[1],&rr[2],&rr[3],&rr[4],&rr[5],&rr[6])>0)        
         { 
           tt[0]=rr[0];
           tt[1]=(rr[1]+rr[2])/2;           
           tt[2]=rr[6];
           
           c1=tt[1]-pp[1];     
           
             
           if(fabs(c1)>c3)
            { for(j=0;j<3;j++)
                pp[j]=tt[j];

                fprintf(fpo,"%8.3lf %8.5lf %8.0lf\n",pp[0],pp[1],pp[2]);              
            }                     
         }
      fprintf(fpo,"%8.3lf %8.5lf %8.0lf\n",pp[0],pp[1],pp[2]);

     fclose(fpi);
     fclose(fpo); 

     exit(0);

    getch();    /* 请不要删除此行 */
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?