<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

    因為口渴,上帝創(chuàng)造了水;
    因為黑暗,上帝創(chuàng)造了火;
    因為我需要朋友,所以上帝讓你來到我身邊
    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經(jīng)典

    OA系統(tǒng)

    Spring在線

    Structs在線

    專家專欄

    企業(yè)信息化

    大型設備共享系統(tǒng)

    工作流

    工作流產(chǎn)品

    網(wǎng)上購書

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

     1 //求出用1,2,5這三個數(shù)不同個數(shù)組合的和為1000的組合個數(shù)。
     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這三個數(shù)不同個數(shù)組合的和為1000的組合個數(shù)(華為面試題目) 2006-10-02 22:04 執(zhí)著人生
    #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這三個數(shù)不同個數(shù)組合的和為1000的組合個數(shù)(華為面試題目) 2006-10-02 22:07 執(zhí)著人生
    樓主的少考慮了全1情況  回復  更多評論
      
    主站蜘蛛池模板: 精品亚洲一区二区| 久久午夜夜伦鲁鲁片无码免费| 中文字幕免费在线看电影大全| 又大又粗又爽a级毛片免费看| 久久水蜜桃亚洲AV无码精品| 久久精品国产亚洲av四虎| 可以免费观看的一级毛片| 麻豆一区二区免费播放网站| 日本高清免费观看| 一个人看的免费观看日本视频www 一个人看的免费视频www在线高清动漫 | 精品视频在线免费观看| 美女黄频免费网站| 亚洲精品一卡2卡3卡四卡乱码| 国产最新凸凹视频免费| 日韩国产免费一区二区三区| 久久精品电影免费动漫| 日韩电影免费在线观看网址| 亚洲中文无码mv| 亚洲AV成人一区二区三区在线看| 亚洲国产a级视频| 国产又大又粗又硬又长免费 | 大地资源在线观看免费高清| 免费国产污网站在线观看15| 中文字幕乱码系列免费| 成年大片免费高清在线看黄| 国产综合激情在线亚洲第一页| 亚洲国产精品无码专区影院| 亚洲日韩在线中文字幕第一页| 免费黄色网址网站| 久久久久高潮毛片免费全部播放 | 亚洲美女视频免费| 四虎国产成人永久精品免费| 3344在线看片免费| 免费91最新地址永久入口| 成人免费无码H在线观看不卡| 久久精品国产亚洲AV久| 国产99在线|亚洲| 亚洲偷自拍另类图片二区| 亚洲欧洲无卡二区视頻| 亚洲一线产品二线产品| 亚洲AV无码精品国产成人|