usaco-namenum-pass

來源:互聯網
上載者:User

標籤:style   blog   color   os   io   ar   for   資料   div   

呵呵,這個,要轉換一下思維,不能被題所導引,感覺代碼有點醜:

/*ID: qq104801LANG: C++TASK: namenum*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <assert.h>/* for debug only:counter*/void debug_dummy(void){    return;}typedef struct _dict{    int n;    char x[5001][13];}dict;dict d;char cc[26]={‘2‘,‘2‘,‘2‘,    ‘3‘,‘3‘,‘3‘,‘4‘,‘4‘,‘4‘,    ‘5‘,‘5‘,‘5‘,‘6‘,‘6‘,‘6‘,    ‘7‘,‘0‘,‘7‘,‘7‘,‘8‘,‘8‘,‘8‘,    ‘9‘,‘9‘,‘9‘,‘0‘};  char s[13],t[13];void initdict(FILE* ff){    FILE *f=fopen("dict.txt","r");    int i=0;    int l=strlen(s);    int k=0;    while(fscanf(f,"%s",&d.x[i])!=EOF)    {        if (l==strlen(d.x[i]))        {            int f=1;            int j=0;            while(j<l)            {                if ((d.x[i][j]>=‘A‘) && (d.x[i][j]<=‘Z‘) && (cc[d.x[i][j]-‘A‘]==s[j]));                    else                    {                        f=0;                                        break;                    }                j++;            }            if (f)            {                                fprintf(ff,"%s\n",d.x[i]);                k++;            }        }                        i++;    }    if(!k)        fprintf(ff,"NONE\n");    fclose(f);    d.n=--i;    }main () {        FILE *fin = fopen ("namenum.in", "r");    FILE *fout = fopen ("namenum.out", "w");     fscanf(fin,"%s",&s);    initdict(fout);           fclose(fin);    fclose(fout);    exit (0);}

測試資料:

USER: ll tom [qq104801]TASK: namenumLANG: C++Compiling...Compile: OKExecuting...   Test 1: TEST OK [0.008 secs, 3556 KB]   Test 2: TEST OK [0.016 secs, 3556 KB]   Test 3: TEST OK [0.019 secs, 3556 KB]   Test 4: TEST OK [0.014 secs, 3556 KB]   Test 5: TEST OK [0.014 secs, 3556 KB]   Test 6: TEST OK [0.008 secs, 3556 KB]   Test 7: TEST OK [0.011 secs, 3556 KB]   Test 8: TEST OK [0.005 secs, 3556 KB]   Test 9: TEST OK [0.014 secs, 3556 KB]   Test 10: TEST OK [0.005 secs, 3556 KB]   Test 11: TEST OK [0.011 secs, 3556 KB]   Test 12: TEST OK [0.014 secs, 3556 KB]   Test 13: TEST OK [0.008 secs, 3556 KB]   Test 14: TEST OK [0.005 secs, 3556 KB]   Test 15: TEST OK [0.014 secs, 3556 KB]All tests OK.Your program (‘namenum‘) produced all correct answers! This is your submission #6 for this problem. Congratulations!Here are the test data inputs:------- test 1 ----4734------- test 2 ----234643------- test 3 ----5747867437------- test 4 ----223------- test 5 ----532------- test 6 ----546------- test 7 ----53662------- test 8 ----5455426------- test 9 ----26678268463------- test 10 ----463373633623------- test 11 ----282742662------- test 12 ----463373633623------- test 13 ----2336------- test 14 ----5264------- test 15 ----426Keep up the good work!Thanks for your submission!

 

usaco-namenum-pass

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.