<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情況  回復  更多評論
      
    主站蜘蛛池模板: 亚洲成AV人片在线观看WWW| 日韩一区二区在线免费观看| 亚洲黄黄黄网站在线观看| 亚洲成a人无码亚洲成av无码| 中国在线观看免费高清完整版 | 成人免费淫片在线费观看| 亚洲性无码av在线| 真实国产乱子伦精品免费| 亚洲激情黄色小说| 无人在线观看完整免费版视频| 亚洲乱码一二三四区国产| 日韩精品无码区免费专区| 四虎亚洲精品高清在线观看| 四虎影院在线免费播放| 国产亚洲视频在线| 亚洲一区二区三区影院| 十九岁在线观看免费完整版电影| 亚洲视频免费一区| 大陆一级毛片免费视频观看| 亚洲国产精品无码中文lv| 亚洲高清成人一区二区三区| 国产一级一毛免费黄片| 久久精品国产亚洲精品2020| AV免费网址在线观看| 色九月亚洲综合网| 亚洲色欲色欲www在线丝| 日韩内射激情视频在线播放免费| 亚洲第一网站免费视频| 成年女人色毛片免费看| igao激情在线视频免费| 亚洲人成网www| 国产又长又粗又爽免费视频| 一个人免费观看视频在线中文| 亚洲AV无码久久精品色欲| 国产免费不卡v片在线观看| 精品国产亚洲一区二区三区在线观看| 精品亚洲视频在线观看 | 美女无遮挡拍拍拍免费视频| 亚洲人成网站在线播放影院在线| 99精品国产免费久久久久久下载| 一级做a爰片性色毛片免费网站|