您好!我是一名新手.现在我有一个很难解决的问题!希望我的朋友们可以帮助我!谢谢! [英] hello!i am a new learner .now i have a question hard for me!i hope my friends can help me !thanks!
本文介绍了您好!我是一名新手.现在我有一个很难解决的问题!希望我的朋友们可以帮助我!谢谢!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include< iostream>
#include< cmath>
#include< string>
使用 命名空间 std;
#define PI 3.1415926
int main()
{
浮动 seisx [ 4375 ] [ 1 ] ,seisy [ 4375 ] [ 1 ],seisr [ 4375 ] [ 1 ],seist [ 4375 ] [ int nsamp = 4375 ,ntraces = 479 ;
for ( int i = 0 ; i< ; nsamp; i ++)
{
seisx [i] [ 1 ] = 0 . 0 ;
seisy [i] [ 1 ] = 0 . 0 ;
seisr [i] [ 1 ] = 0 . 0 ;
seist [i] [ 1 ] = 0 . 0 ;
}
int sr [ 179 ] [ 1 ] ,st [ 179 ] [ 1 ];
(i = 0 ; i< 179; i ++) // 错误:存在一个无限循环.当它是179时,存在一个无限循环.它是179,没有无限循环.
{
sr [i] [ 1 ] = 0 ;
st [i] [ 1 ] = 0 ;
cout<< sr [i] [ 1 ]<< " << st [i] [ 1 ]<< " "<< i<< endl;
}
文件* fp1,* fp2,* fp3,* fp4;
fp1 = fopen(" ," );
fp2 = fopen(" ," );
fp3 = fopen(" ," );
fp4 = fopen(" ," );
for ( int seqno = 345 ; seqno< ; ntraces; seqno ++)
{
cout<< seqno + 1<< endl;
fseek(fp1,长(3600+(seqno + 1)* 240 + seqno * nsamp * 4), 0 );
for ( int i = 0 ; i< ; nsamp; i ++)
{
fread(& seisx [i] [ 1 ], 4 ,nsamp + 1,fp1);
// cout<< seisx [i] [1]<"<<< i<<< ; endl;
}
fseek(fp2,长(3600+(seqno + 1)* 240 + seqno * nsamp * 4), 0 );
fread(seisy, 4 ,nsamp + 1,fp2);
cout<< seisx [seqno] [ 1 ]<<< seisx [seqno] [ 1 ] << endl;
float seismaxr1 = 0 . 0 ,seismaxr2 = 0 . 0 ; // xMax = 0.0,yMax = 0.0;
int rind1,rind2,rind;
for (i = 0 ; i< nsamp; i ++)
{
如果(abs(seisy [i] [ 1 ])> seismaxr1)
{
seismaxr1 = abs(seisy [i] [ 1 ]);
rind1 = i;
}
如果(abs(seisx [i] [ 1 ])> seismaxr2)
{
seismaxr2 = abs(seisx [i] [ 1 ]);
rind2 = i;
}
}
cout< rind2<< endl;
如果(seismaxr2> seismaxr1)
rind = rind2;
其他
rind = rind1;
float seisrmax = 0 . 0 ;
int seisindex;
如果((seisx [rind] [ 1 ] * seisy [rind] [ for ( int j = 1 ; j< ; = 179 ; j ++)
{
浮动 t =(j * PI)/180;
sr [j-1] [ 1 ] = pow((cos(t)* seisx [rind] [ 1 ] + sin(t)* seisy [rind] [ 1 ]), 2 . 0 );
st [j-1] [ 1 ] = pow((((-1)* cos(t)* seisy [rind] [ 1 ]), 0 );
}
for (j = 1 ; j< = 179 ; i ++)
如果(abs(sr [j-1] [ 1 ])> seisrmax)
{
seisrmax = abs(sr [j-1] [ 1 ]);
seisindex = j;
}
for ( int k = 0 ; k< ; nsamp; k ++)
{
seisindex = seisindex * PI/180;
seisr [k] [ 1 ] = cos(seisindex)* seisx [k] [ 1 ] + sin (seisindex)* seisy [k] [ 1 ];
seist [k] [ 1 ] =(-1)* cos(seisindex)* seisy [k] [ 1 ] + sin(seisindex)* seisx [k] [ 1 ];
}
}
其他
{
for ( int j = 1 ; j< ; = 179 ; j ++)
{
浮动 t =(j * PI)/180;
sr [j-1] [ 1 ] = pow((((-1)* cos(t)* seisx [rind] [ 1 ]), 0 );
st [j-1] [ 1 ] = pow((cos(t)* seisy [rind] [ 1 ] + sin(t)* seisx [rind] [ 1 ]), 2 . 0 );
}
float seisrmax = 0 . 0 ;
int seisindex;
for (j = 1 ; j< = 179 ; i ++)
如果(abs(sr [j-1] [ 1 ])> seisrmax)
{
seisrmax = abs(sr [j-1] [ 1 ]);
seisindex = j;
}
for ( int k = 0 ; k< ; nsamp; k ++)
{
seisindex = seisindex * PI/180;
seisr [k] [ 1 ] =(-1)* cos(seisindex)* seisx [k] [ 1 ] + sin(seisindex)* seisy [k] [ 1 ];
seist [k] [ 1 ] = cos(seisindex)* seisy [k] [ 1 ] + sin (seisindex)* seisx [k] [ 1 ];
}
}
fseek(fp3,长(3600 + seqno *(nsamp + 60)* 4 + 180), 0 );
fwrite(& seisindex, 4 , 1 ,fp3);
fseek(fp3,长(3600 + seqno *(nsamp + 60)* 4 + 240), 0 );
for (i = 0 ; i< nsamp; i ++)
fwrite(& seist [i] [ 1 ], 4 ,长(3600 + seqno *(nsamp + 60)* 4 + 180), 0 );
fwrite(& seisindex, 4 , 1 ,fp4);
fseek(fp4,长(3600 + seqno *(nsamp + 60)* 4 + 240), 0 );
for (i = 0 ; i< nsamp; i ++)
fwrite(& seisr [i] [ 1 ], 4 ,返回 0 ;
}
解决方案
那肯定是一个漂亮的代码块,但是如果没有解释您需要什么帮助,那是毫无意义的. /blockquote>
谢谢!我已经解决了这个问题!
#include <iostream> #include <cmath> #include <string> using namespace std; #define PI 3.1415926 int main() { float seisx[4375][1],seisy[4375][1],seisr[4375][1],seist[4375][1]; int nsamp=4375,ntraces=479; for(int i=0;i<nsamp;i++) { seisx[i][1]=0.0; seisy[i][1]=0.0; seisr[i][1]=0.0; seist[i][1]=0.0; } int sr[179][1],st[179][1]; for(i=0;i<179;i++) //errors:there is a Infinite loop.when it is 179,there is a infinite loop.it is 179,there is not. { sr[i][1]=0; st[i][1]=0; cout<<sr[i][1]<<" "<<st[i][1]<<" "<<i<<endl; } FILE *fp1,*fp2,*fp3,*fp4; fp1=fopen("D:\\programming\\matlab\\h17609400x.segy","r"); fp2=fopen("D:\\programming\\matlab\\h17609400y.segy","r"); fp3=fopen("D:\\programming\\matlab\\h17609400t.segy","rb+"); fp4=fopen("D:\\programming\\matlab\\h17609400r.segy","rb+"); for(int seqno=345;seqno<ntraces;seqno++) { cout<<seqno+1<<endl; fseek(fp1,long(3600+(seqno+1)*240+seqno*nsamp*4),0); for(int i=0;i<nsamp;i++) { fread(&seisx[i][1],4,nsamp+1,fp1); // cout<<seisx[i][1]<<" "<<i<<endl; } fseek(fp2,long(3600+(seqno+1)*240+seqno*nsamp*4),0); fread(seisy,4,nsamp+1,fp2); cout<<seisx[seqno][1]<<seisx[seqno][1]<<endl; float seismaxr1=0.0,seismaxr2=0.0; //xMax=0.0,yMax=0.0; int rind1,rind2,rind; for(i=0;i<nsamp;i++) { if(abs(seisy[i][1])>seismaxr1) { seismaxr1=abs(seisy[i][1]); rind1=i; } if(abs(seisx[i][1])>seismaxr2) { seismaxr2=abs(seisx[i][1]); rind2=i; } } cout<<rind2<<endl; if(seismaxr2>seismaxr1) rind=rind2; else rind=rind1; float seisrmax=0.0; int seisindex; if((seisx[rind][1]*seisy[rind][1])>0) { for(int j=1;j<=179;j++) { float t=(j*PI)/180; sr[j-1][1]=pow((cos(t)*seisx[rind][1]+sin(t)*seisy[rind][1]),2.0); st[j-1][1]=pow(((-1)*cos(t)*seisy[rind][1]+sin(t)*seisx[rind][1]),2.0); } for(j=1;j<=179;i++) if(abs(sr[j-1][1])>seisrmax) { seisrmax=abs(sr[j-1][1]); seisindex=j; } for(int k=0;k<nsamp;k++) { seisindex=seisindex*PI/180; seisr[k][1]=cos(seisindex)*seisx[k][1]+sin(seisindex)*seisy[k][1]; seist[k][1]=(-1)*cos(seisindex)*seisy[k][1]+sin(seisindex)*seisx[k][1]; } } else { for(int j=1;j<=179;j++) { float t=(j*PI)/180; sr[j-1][1]=pow(((-1)*cos(t)*seisx[rind][1]+sin(t)*seisy[rind][1]),2.0); st[j-1][1]=pow((cos(t)*seisy[rind][1]+sin(t)*seisx[rind][1]),2.0); } float seisrmax=0.0; int seisindex; for(j=1;j<=179;i++) if(abs(sr[j-1][1])>seisrmax) { seisrmax=abs(sr[j-1][1]); seisindex=j; } for(int k=0;k<nsamp;k++) { seisindex=seisindex*PI/180; seisr[k][1]=(-1)*cos(seisindex)*seisx[k][1]+sin(seisindex)*seisy[k][1]; seist[k][1]=cos(seisindex)*seisy[k][1]+sin(seisindex)*seisx[k][1]; } } fseek(fp3,long(3600+seqno*(nsamp+60)*4+180),0); fwrite(&seisindex,4,1,fp3); fseek(fp3,long(3600+seqno*(nsamp+60)*4+240),0); for(i=0;i<nsamp;i++) fwrite(&seist[i][1],4,1,fp3); fseek(fp4,long(3600+seqno*(nsamp+60)*4+180),0); fwrite(&seisindex,4,1,fp4); fseek(fp4,long(3600+seqno*(nsamp+60)*4+240),0); for(i=0;i<nsamp;i++) fwrite(&seisr[i][1],4,1,fp4); } fclose(fp1); fclose(fp2); fclose(fp3); fclose(fp4); return 0; }解决方案That sure is a pretty block of code, but without an explanation of what you want help with, it''s kinda pointless.
thank you!i have solved this question!
这篇关于您好!我是一名新手.现在我有一个很难解决的问题!希望我的朋友们可以帮助我!谢谢!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文