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 |
为什么总是WA?求助各位大牛#include<stdio.h> #include<math.h> #define N 300 int DtoS(int n) { int i,m,b[N]; i=0; while(n) { b[i]=n%7; n=n/7; i++; } m=0; while(i--) m+=b[i]*pow(10,i); return m; } int StoD(int n) { int i,b,c,cout=0; i=1; c=10; while(n/c) {i++; c*=10; } c=1; b=1; while(i--) { cout+=(n/b%10)*c; c*=7; b*=10; } return cout; } int max(int a,int b) { if(a>=b) return a; else return b; } int min(int a,int b) { if(a>=b) return b; else return a; } void main() { int n,d,b,e,i,a[N],num,set; scanf("%d",&num); set=1; while(num--) { scanf("%d%d%d%d",&n,&d,&b,&e); printf("Problem set %d: %d / %d, base 7 digits %d through %d: ",set,n,d,b,e); n%=d; n=DtoS(n); d=DtoS(d); i=0; while(i<=max(b,e)) { a[i]=StoD(10*n)/StoD(d); n=StoD(10*n)%StoD(d); n=DtoS(n); i++; } i=min(b,e); while(i<=max(b,e)) {printf("%d",a[i]); i++; } set++; printf("\n"); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator