• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            糯米

            TI DaVinci, gstreamer, ffmpeg
            隨筆 - 167, 文章 - 0, 評論 - 47, 引用 - 0
            數據加載中……

            POJ 2389 Bull Math 高精度整數

            注意:
            要去掉前面的0再輸出。


            #include <stdio.h>
            #include 
            <string.h>

            struct node {
                
            char arr[128];
                
            int len;
            }
            ;

            __inline 
            int max(int a, int b)
            {
                
            return a > b ? a : b;
            }


            __inline 
            void add(struct node *a, struct node *b)
            {
                
            int i, val;

                
            for (val = i = 0; i < max(a->len, b->len); i++{
                    
            if (i < a->len)
                        val 
            += a->arr[i];
                    
            if (i < b->len)
                        val 
            += b->arr[i];
                    a
            ->arr[i] = val % 10;
                    val 
            /= 10;
                }

                
            if (val)
                    a
            ->arr[i++= val;
                a
            ->len = i;
            }


            __inline 
            void mul_single(struct node *a, int val, int pad, struct node *c)
            {
                
            int i, r;

                
            for (i = 0; i < pad; i++)
                    c
            ->arr[i] = 0;
                c
            ->len = pad;
                
            for (r = i = 0; i < a->len; i++{
                    r 
            += a->arr[i] * val;
                    c
            ->arr[c->len++= r % 10;
                    r 
            /= 10;
                }

                
            if (r)
                    c
            ->arr[c->len++= r;
            }


            __inline 
            void mul(struct node *a, struct node *b, struct node *c)
            {
                
            struct node t;
                
            int i;

                c
            ->len = 0;
                
            for (i = 0; i < a->len; i++{
                    mul_single(b, a
            ->arr[i], i, &t);
                    add(c, 
            &t);
                }

            }


            __inline 
            void input(struct node *t)
            {
                
            char str[sizeof(t->arr)];
                
            int i, len;

                scanf(
            "%s", str);
                len 
            = strlen(str);
                t
            ->len = 0;
                
            for (i = len - 1; i >= 0; i--)
                    t
            ->arr[t->len++= str[i] - '0';
            }


            __inline 
            void output(struct node *t)
            {
                
            int i;

                
            for (i = t->len - 1; i >= 0 && !t->arr[i]; i--);
                
            if (i < 0{
                    printf(
            "0\n");
                    
            return ;
                }

                
            for ( ; i >= 0; i--)
                    putc(t
            ->arr[i] + '0', stdout);
                putc(
            '\n', stdout);
            }


            int main()
            {
                
            struct node a, b, c;

                freopen(
            "e:\\test\\in.txt""r", stdin);

                input(
            &a);
                input(
            &b);
                mul(
            &a, &b, &c);
                output(
            &c);

                
            return 0;
            }

            posted on 2010-03-14 00:08 糯米 閱讀(250) 評論(0)  編輯 收藏 引用 所屬分類: POJ

            久久无码人妻精品一区二区三区| 777午夜精品久久av蜜臀| 国产精品免费久久久久电影网| 无夜精品久久久久久| 999久久久国产精品| 国产成人精品久久| 久久人人爽人人爽人人片AV不| 久久久久亚洲国产| 久久只这里是精品66| 人妻丰满AV无码久久不卡| 久久久久久夜精品精品免费啦| 国内精品伊人久久久影院| 热re99久久精品国99热| 久久久久99精品成人片牛牛影视| 伊人久久大香线蕉亚洲| 久久久久亚洲AV无码网站| 大香伊人久久精品一区二区| 97久久精品国产精品青草| 久久精品国产色蜜蜜麻豆| 久久精品视频一| 狠狠色丁香久久综合五月| 久久精品综合网| 欧美牲交A欧牲交aⅴ久久| 久久久久国色AV免费观看| 精品亚洲综合久久中文字幕| 久久精品国产亚洲AV电影| 中文字幕亚洲综合久久菠萝蜜 | 欧美日韩精品久久免费| 久久精品男人影院| 精品综合久久久久久888蜜芽| 久久SE精品一区二区| 久久激情亚洲精品无码?V| 亚洲欧美久久久久9999| 久久99精品国产麻豆婷婷| 奇米综合四色77777久久| 精品国产乱码久久久久久人妻 | 性做久久久久久久久| 久久综合精品国产二区无码| 少妇人妻88久久中文字幕| 99久久国产亚洲高清观看2024 | 久久综合九色综合久99|