Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

痛苦的经历:忘记删掉debug语句就去submit,得到了两个宝贵的ole

Posted by fanhqme at 2008-10-01 14:33:44 on Problem 1350
作为惩罚,贴出自己的ole代码

#include <cstdio>
using namespace std;
int sort_s(int a){
    int b[10],bc,t;
    for (bc=0;a;bc++){b[bc]=a%10;a/=10;}
    for (int i=0;i<bc;i++)for (int j=i;j<bc;j++)if (b[i]>b[j]){t=b[i];b[i]=b[j];b[j]=t;}
    for (int i=t=0;i<bc;i++)t=10*t+b[i];
    return t;
}
int sort_b(int a){
    int b[10],bc,t;
    for (bc=0;a;bc++){b[bc]=a%10;a/=10;}
    for (int i=0;i<bc;i++)for (int j=i;j<bc;j++)if (b[i]<b[j]){t=b[i];b[i]=b[j];b[j]=t;}
    for (int i=t=0;i<bc;i++)t=10*t+b[i];
    return t;
}
int chklen(char *a){for (int i=0;i<200;i++)if (a[i]==0)return i;return 200;}
int chksame(char *a){for (int i=1;i<4;i++)if (a[i]!=a[0])return 0;return 1;}
int main()
{
    char chs[200];
    int t,d1,d2,dc;
    for (gets(chs);chs[0]!='-';gets(chs)){
        printf("N=%s:\n",chs);
        dc=chs[0]*1000+chs[1]*100+chs[2]*10+chs[3]-'0'*1111;
        if (chklen(chs)!=4 || chksame(chs) || dc<1000)puts("No!!");
        else{
             for (t=0;dc && dc!=6174;t++){
                 d1=sort_s(dc);d2=sort_b(dc);
                 printf("%d-%d=%d\n",d2,d1,d2-d1);
                 getchar();
                 dc=d2-d1;
             }
             printf("Ok!! %d times\n",t);
        }
    }
    return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator