302班

          java突擊隊
          posts - 151, comments - 74, trackbacks - 0, articles - 14
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          將數字轉化為英文單詞

          Posted on 2007-07-02 00:41 停留的風 閱讀(1045) 評論(1)  編輯  收藏

          #include <stdio.h>
          int main(void)
          {
            int number,temp,length=3;
             printf("Enter an int three unit number!\n");
            scanf("%i",&number);

            int sum[3];
            while(number!=0)
            { 
              temp=number%10;
              sum[length-1]=temp;
           length--;
           number=number/10;
            }
            for(int i=0;i<3;i++)
            {
               switch(sum[i])
            {
               case 0:
                     printf("zero ");
               break;
            case 1:
             printf("one ");
             break;
                  case 2:
                     printf("two ");
               break;
            case 3:
             printf("three ");
             break;
            case 4:
                     printf("four ");
            case 5:
             printf("five ");
             break;
               case 6:
                     printf("six ");
               break;
            case 7:
             printf("seven ");
             break;
            case 8:
             printf("enght ");
             break;
            case 9:
             printf("nine ");
             break;
            default:
             printf("Unknown char not a number!");
              break;
           
            }
            }
            printf("\n");
           
            return 0;
           
          }
          測試結果:


          評論

          # re: 將數字轉化為英文單詞  回復  更多評論   

          2009-03-11 21:26 by 韋秀娟
          10

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 临颍县| 崇阳县| 高邮市| 太原市| 德阳市| 曲水县| 米泉市| 河间市| 五常市| 江源县| 出国| 库车县| 郁南县| 栖霞市| 神池县| 万州区| 交口县| 芒康县| 安泽县| 湘阴县| 武乡县| 毕节市| 兴和县| 长汀县| 二手房| 禹城市| 海原县| 望都县| 柳林县| 修水县| 奉新县| 商城县| 砚山县| 沙湾县| 宜兰市| 合江县| 会同县| 于都县| 辽宁省| 周至县| 揭东县|