<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 71  文章 - 15  trackbacks - 0
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    因為口渴,上帝創造了水;
    因為黑暗,上帝創造了火;
    因為我需要朋友,所以上帝讓你來到我身邊
    Click for Shaanxi xi'an, Shaanxi Forecast
    ╱◥█◣
      |田|田|
    ╬╬╬╬╬╬╬╬╬╬╬
    If only I have such a house!
    〖總在爬山 所以艱辛〗
    Email:myesjoy@yahoo.com.cn
    NickName:yesjoy
    MSN:myesjoy@hotmail.com
    QQ:150230516

    〖總在尋夢 所以苦痛〗

    常用鏈接

    留言簿(3)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    Hibernate在線

    Java友情

    Java認證

    linux經典

    OA系統

    Spring在線

    Structs在線

    專家專欄

    企業信息化

    大型設備共享系統

    工作流

    工作流產品

    網上購書

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

     1 //求出用1,2,5這三個數不同個數組合的和為1000的組合個數。
     2 //如:100個1是一個組合,5個1加19個5是一個組合。。。。
     3   public class getNumbers{ 
     4    public static void sums1(int temp)
     5    {
     6    int num1 = temp/1;
     7    int num2 = temp/2;
     8    int num3 = temp/5;
     9    int numbers = 0;
    10    String values; 
    11    for(int i=0;i<num1;i++)
    12    {
    13    for(int j=0;j<num2;j++)
    14    {
    15    for(int k=0;k<num3;k++)
    16    {
    17    if((1*i+2*j+5*k)==temp)
    18    {
    19    numbers++
    20    values = i+“個1,“+j+“個2,“+k+“個5“;
    21    System.out.println(“the “+numbers+“ groups numbers is:“+values);
    22    }
    23    }
    24    }
    25    }
    26    System.out.println(“the numbers of group is ===>+numbers);
    27    }
    28    public static void main(String[] args) {
    29    int s = 1000;
    30    sums1(s);
    31    }
    32   }
    33   
     1 運行結果:
     2   E:\java\ProgramJava\csdn>javac getNumbers.java
     3   E:\java\ProgramJava\csdn>java getNumbers >>groups.txt
     4   groups.txt中的輸出結果如下:
     5   the 1 groups numbers is:0個1,5個2,198個5
     6   the 2 groups numbers is:0個1,10個2,196個5
     7   the 3 groups numbers is:0個1,15個2,194個5
     8   the 4 groups numbers is:0個1,20個2,192個5
     9   the 5 groups numbers is:0個1,25個2,190個5
    10   the 6 groups numbers is:0個1,30個2,188個5
    11   the 7 groups numbers is:0個1,35個2,186個5
    12   the 8 groups numbers is:0個1,40個2,184個5
    13   the 9 groups numbers is:0個1,45個2,182個5
    14   the 10 groups numbers is:0個1,50個2,180個5
    15   the 11 groups numbers is:0個1,55個2,178個5
    16   the 12 groups numbers is:0個1,60個2,176個5
    17   the 13 groups numbers is:0個1,65個2,174個5
    18   the 14 groups numbers is:0個1,70個2,172個5
    19   the 15 groups numbers is:0個1,75個2,170個5
    20   the 16 groups numbers is:0個1,80個2,168個5
    21   …………
    22   the 50379 groups numbers is:983個1,6個2,1個5
    23   the 50380 groups numbers is:984個1,3個2,2個5
    24   the 50381 groups numbers is:984個1,8個2,0個5
    25   the 50382 groups numbers is:985個1,0個2,3個5
    26   the 50383 groups numbers is:985個1,5個2,1個5
    27   the 50384 groups numbers is:986個1,2個2,2個5
    28   the 50385 groups numbers is:986個1,7個2,0個5
    29   the 50386 groups numbers is:987個1,4個2,1個5
    30   the 50387 groups numbers is:988個1,1個2,2個5
    31   the 50388 groups numbers is:988個1,6個2,0個5
    32   the 50389 groups numbers is:989個1,3個2,1個5
    33   the 50390 groups numbers is:990個1,0個2,2個5
    34   the 50391 groups numbers is:990個1,5個2,0個5
    35   the 50392 groups numbers is:991個1,2個2,1個5
    36   the 50393 groups numbers is:992個1,4個2,0個5
    37   the 50394 groups numbers is:993個1,1個2,1個5
    38   the 50395 groups numbers is:994個1,3個2,0個5
    39   the 50396 groups numbers is:995個1,0個2,1個5
    40   the 50397 groups numbers is:996個1,2個2,0個5
    41   the 50398 groups numbers is:998個1,1個2,0個5
    42   the numbers of group is ===>50398
    43   
     1   #include<iostream>
     2   using namespace std;
     3   void main()
     4   {
     5    int i,j,n=0;
     6    for(i=0;i<=20;i++)
     7    {
     8    for(j=0;j<=(100-i*5)/2;j++)
     9    {
    10    n++;
    11    }
    12    }
    13    cout<<n<<endl;
    14   }
     1   #include <stdio.h>
     2   int main(void)
     3   {
     4    int j,k,n;
     5   
     6    for(j=0;j<=50;j++)
     7    {
     8    for(k=0;k<=20;k++)
     9    {
    10    if(2*j+5*k<=100)
    11    n++;
    12    }
    13    }
    14    
    15    printf(“count=%d\n“,n);
    16   }
    posted on 2006-01-19 14:51 ★yesjoy★ 閱讀(2031) 評論(2)  編輯  收藏 所屬分類: 算法總結

    FeedBack:
    # re: 求出用1,2,5這三個數不同個數組合的和為1000的組合個數(華為面試題目) 2006-10-02 22:04 執著人生
    #include<iostream.h>
    void main()
    {
    int sum = 0;
    int i,j,k;
    for(i = 0; i <= 1000; ++i)
    for(j = 0;j <= 500;++j)
    for(k = 0; k <= 200;++k)
    {
    if(1*i + 2*j + 5*k == 1000)
    ++sum;
    }
    cout<<"The result is : "<<sum;
    }  回復  更多評論
      
    # re: 求出用1,2,5這三個數不同個數組合的和為1000的組合個數(華為面試題目) 2006-10-02 22:07 執著人生
    樓主的少考慮了全1情況  回復  更多評論
      
    主站蜘蛛池模板: 美女又黄又免费的视频| 亚洲综合亚洲国产尤物| 最新亚洲人成无码网www电影| 免费福利网站在线观看| 337p日本欧洲亚洲大胆艺术| 99爱在线观看免费完整版| 亚洲人成在线播放网站岛国| 国产精品视频白浆免费视频| 亚洲天堂男人天堂| **aaaaa毛片免费| 成av免费大片黄在线观看| 国产亚洲av片在线观看18女人| 国产美女视频免费观看的网站| 亚洲免费观看视频| 婷婷国产偷v国产偷v亚洲| 亚洲Av无码乱码在线播放| 国产一级a毛一级a看免费视频 | 无码日韩精品一区二区免费暖暖| 日木av无码专区亚洲av毛片| 鲁啊鲁在线视频免费播放| 亚洲午夜精品第一区二区8050| 大妹子影视剧在线观看全集免费| 亚洲第一中文字幕| 最近中文字幕mv免费高清电影| 日韩精品亚洲专区在线影视| 久久久久久久亚洲精品| 久久久久久精品成人免费图片 | 久久成人无码国产免费播放| 亚洲成A∨人片在线观看无码| 有色视频在线观看免费高清在线直播 | 成人嫩草影院免费观看| 国产亚洲精品xxx| 国产1000部成人免费视频| 美女黄色毛片免费看| 亚洲国产高清在线| 天天天欲色欲色WWW免费| 久久er国产精品免费观看8| 亚洲成人免费电影| 国产精品亚洲视频| 欧美男同gv免费网站观看| 精品亚洲成a人片在线观看少妇 |