|
|
вернуться в форумwhy i always got access_violation?help Послано zhi 1 мар 2002 21:00 This is my program.What is the problem with my program?Please tell me. Thank you! #include<iostream.h> #include<string.h> #include<stdlib.h> char* str; int f(char* s){ char max='0'; for(long lop=0;s[lop]!='\0';lop++) if(s[lop]>max)max=s[lop]; if(max<'2')return 2; if(max<='9')return int(max-'0'+1); return int(max-'A'+11); } int num(char s){ if(s<='9')return int(s-'0'); return int(s-'A'+10); } void main(){ str=new char[950010]; cin>>str; long l; for(l=0;str[l]!='\0';l++)if(l>=950010)exit(1); int lop; unsigned long h; unsigned long temp; for(int k=f(str);k<=36;k++) { temp=0; h=0; int y=l%5; if(y!=0) for(lop=0;lop<y;lop++) { temp=temp*k; temp+=num(str[h]); h++; if(h==l) break; } while(h!=l) { temp=temp%(k-1); for(lop=0;lop<5;lop++) { temp=temp*k; temp+=num(str[h]); h++; if (h==l) break; } } if(temp%(k-1)==0){cout<<k<<endl;exit(1);} } cout<<"No solution."<<endl; } it needn't keep all number in array it needn't keep all number in array if u know (m+n)%k = ((m%k)+(n%k))%k Could you say it more clearly? I can't understand. Послано Koala 26 июл 2002 17:09 > it needn't keep all number in array > if u know > (m+n)%k = ((m%k)+(n%k))%k |
|
|