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

界面编程

开发平台:

C/C++

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