|
|
back to boardwhere is my mistake? help me Posted by ooo 11 Dec 2008 20:11 #include <iostream.h> int sum(int); int main() {unsigned int i,m; long a[1000000],I,J; cin>>I>>J; for(i=0;i<=J-I;i++) {a[i]=(sum(I))/I;I++;} m=a[0]; for(i=1;i<=J-I;i++) if(a[i]<m) m=a[i]; cout<<m; return 0;} int sum(int x) {int s=0; while(x!=0) {s+=x%10; x/=10;} return s;} Re: where is my mistake? help me Posted by ooo 12 Dec 2008 00:21 #include <iostream.h> double a[1000000]; int sum(int); int main() {unsigned int i; double N,I,J; cin>>I>>"/">>J; for(i=0;i<J-I;i++) {a[i]=(sum(I))/I;I++;} N=a[0]; for(i=1;i<J-I;i++) if(a[i]<N) N=a[i]; cout<<N; return 0;} int sum(int x) {int s=0,i; for(i=1;i<=x/2;i++) if(x%i==0) s+=i; return s;} |
|
|