Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
快疯了,谁救一下我!为什么当输入2,3,5时a[0]会等于0呢?#include<iostream> #include<algorithm> #include<cmath> using namespace std; int main() { __int64 t,k,pk,t1,j,i1,n,p1,p2,p3,sum; __int64 a[3000]; int i; long double p; pk=pow((double)10,(double)18); //cout<<"pk:"<<pk<<endl; while(cin>>p1>>p2>>p3>>i) { k=0; for(j=0;j<60;j++) for(t=0;t<60;t++) for(n=0;n<60;n++) { p=pow((double)p1,(double)j)*pow((double)p2,(double)t)*pow((double)p3,(double)n); if(p<=pk) { a[k]=p; //cout<<"a["<<k<<"]"<<a[k]<<endl; k++; } else break; } sort(a,a+k);cout<<a[0]<<endl ;//为什么当输入的p1,p2,p3为2,3,5时a[0]=0?上面的a[k]=p中p可能等于0吗??哪里错了?? // for(j=0;j<200;j++) // cout<<"a["<<j<<"]"<<a[j]<<endl; // cin>>i; if(a[0]==0)cout<<a[i+1]<<endl; else cout<<a[i]<<endl; } delete[]a; return 0; } // 提交n次,老是运行出错~,somebody helps me~~ Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator