READVAL.C
资源名称:C.rar [点击查看]
上传用户:qq5388545
上传日期:2022-07-04
资源大小:29849k
文件大小:2k
源码类别:

界面编程

开发平台:

C/C++

  1. #include "stdio.h"
  2. #define MAX 5000
  3. void main()
  4. {
  5. FILE *fp1,*fp2,*fp3;
  6. float ver[50];
  7. int nodenum,t[14],i,j;
  8. int num_node[4];
  9. int node_number;
  10. float val[MAX];
  11. char ch,s1[80],s2[80],s3[80],val_name[80];
  12. float nodex[MAX],nodey[MAX],nodez[MAX];
  13. int *p1;
  14. float *px,*py,*pz,*pnode;
  15. px=nodex;py=nodey;pz=nodez;
  16. pnode=val;
  17. printf("Please enter ele_node_data filename:");
  18. gets(s1);
  19. if((fp1=fopen(s1,"r"))==NULL){
  20. printf("tnCannot open the file or file not find!n");
  21. exit(1);
  22. }
  23. printf("Please enter val_out_data filename:");
  24. gets(s3);
  25. if((fp3=fopen(s3,"r"))==NULL){
  26. printf("tnCannot open the file or file not find!n");
  27. exit(1);
  28. }
  29. printf("Reading datas......n");
  30. for(i=0;i<=18;i++)
  31. fscanf(fp1,"%c",&ch);
  32. fscanf(fp1,"%f%d",&ver[0],&nodenum);
  33. for(i=0;i<=13;i++)
  34. fscanf(fp1,"%d",&t[i]);
  35. fscanf(fp1,"%f",&ver[0]);
  36. for(i=0;i<=6;i++)
  37. fscanf(fp1,"%d",&t[i]);
  38. fscanf(fp1,"%f%f%f",&px[0],&py[0],&pz[0]);
  39. fscanf(fp1,"%d%f%d%d",&t[0],&ver[0],&t[1],&t[2]);
  40. for(j=1;j<=nodenum-1;j++)
  41. {
  42. for(i=0;i<=6;i++)
  43. fscanf(fp1,"%d",&t[i]);
  44. {
  45.   fscanf(fp1,"%f%f%f",&px[j],&py[j],&pz[j]);
  46.   fscanf(fp1,"%d%f",&t[0],&ver[0]);
  47.   }
  48. }
  49. for(i=1;i<=64;i++)
  50. {
  51. fscanf(fp3,"%c",&ch);
  52. }
  53. fscanf(fp3,"%s",val_name);
  54. rewind(fp3);
  55. for(i=1;i<=111;i++)
  56. {
  57. fscanf(fp3,"%c",&ch);
  58. if(i>=100&&ch=='1'){break;}
  59. }
  60. printf("Please input savedata filename:");
  61. gets(s2);
  62. if((fp2=fopen(s2,"w"))==NULL){
  63. printf("tnCannot open the file!n");
  64. exit(1);
  65. }
  66. printf("nSaving datas......n");
  67. fprintf(fp2,"NODEt X_COORt        Y_COORt       Z_COORt      %s VALn",val_name);
  68. for(j=0;j<=nodenum-1;j++)
  69. {
  70. fscanf(fp3,"%d",&num_node[3]);
  71. for(i=1;i<=6;i++)
  72. fscanf(fp3,"%c",&ch);
  73. fscanf(fp3,"%f",&pnode[j]);
  74. fprintf(fp2,"%dt",j+1);
  75. fprintf(fp2,"%12.6e   %12.6e   %12.6e   %12.6en",px[j],py[j],pz[j],pnode[j]);
  76. }
  77. fprintf(fp2,"****************************n");
  78. for(i=0;i<=7;i++)
  79. fscanf(fp1,"%d",&t[i]);
  80. for(i=0;i<=33;i++)
  81. fscanf(fp1,"%f",&ver[i]);
  82. fprintf(fp2,"NUMtItJtKtLn");
  83. for(i=0;i<=t[1]-1;i++)
  84. {
  85. p1=num_node;
  86. fscanf(fp1,"%d",&t[4]);
  87. fprintf(fp2,"%dt",t[4]);
  88. for(j=0;j<=3;j++)
  89. {
  90.  fscanf(fp1,"%d",&p1[j]);
  91.  fprintf(fp2,"%dt",p1[j]);
  92.  if(j==3)fprintf(fp2,"n");
  93. }
  94. fscanf(fp1,"%d%f%f%d%d%f",&t[2],&ver[0],&ver[1],&t[3],&t[4],&ver[2]);
  95. if(kbhit())if(getch()==27)break;
  96. }
  97. printf("nntaProgram is over!n");
  98. printf("t******************n");
  99. fclose(fp1);
  100. fclose(fp2);
  101. }
  102. /********************************************************/