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 |
这样找不好么?但是超时,求解#include <iostream> #include <math.h> #include<stdio.h> #include <memory.h> using namespace std; int x[10]= {0}; int y; int main() { int a,b; while(1) { cin>>a>>b; memset(x,0,sizeof(x)); if(a==0&&b==0) break; if(a<b) { for(int j=a; j<=b; j++) { int l=(int)log10((double)j)+1; y=j; for(int i=1; i<=l; i++) { x[y%10]++; y=y/10; } } } else { for(int j=b; j<=a; j++) { int l=(int)log10((double)j)+1; y=j; for(int i=1; i<=l; i++) { x[y%10]++; y=y/10; } } } for(int i=0; i<=9; i++) { cout<<x[i]<<" "; } cout<<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