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 |
Re:看出问题的不吝赐教,谢谢In Reply To:看出问题的不吝赐教,谢谢 Posted by:Huacm42 at 2006-08-24 23:25:54 > 不知为何在编译时出现死循环,想了许久没有头绪,哪位大虾指点一下谢谢~! > #include<iostream> > using namespace std; > int main() > { > int a[1501],i,k,k1=1,n,s=1,flag; > while(s<=1500) > { > k=k1; > while(1) > { > flag=0; //每次将flag重新置0 > if(k%2==0) {k/=2;flag=1;} > if(k%3==0) {k/=3;flag=1;}//若可整除就置为1 > if(k%5==0) {k/=5;flag=1;} > if(flag==0||k==1) break; > } > if(k==1) {a[s]=k1;s++;} //k=1是 符合条件的数 > k1++; > > } > while(1) > { > cin>>n; > if(n==0) break; > cout<<a[n]<<endl; > } > return 0; > } 算法错误呀! Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator