隨筆 - 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+3  + 100
           2 public class getSum { 
           3  public static void sums1(int temp)
           4  {
           5   int addResult1=0;
           6   addResult1 = (1+temp)*temp/2;    
           7   System.out.println("addResult1===>"+addResult1);
           8  }
           9  public static void sums2(int temp)
          10  {
          11   int i;
          12   int addResult2 = 0;
          13   for(i=1;i<(temp+1);i++)
          14   {
          15    addResult2 = addResult2 + i;
          16   }
          17   System.out.println("addResult2===>"+addResult2);
          18  }
          19  public static void main(String[] args) {
          20   int s = 100;
          21   sums1(s);
          22   sums2(s);
          23  }
          24 }
          25 
          1   private void countNo(){
          2    int iStart = 1;
          3    int iEnd = 100;
          4    int iCount = 100;
          5   
          6    System.out.println((iStart + iEnd ) * iCount / 2);
          7   }
          8 
          9 
          1#include<stdio.h>
          2void main()
          3{
          4 int a=0,sum=0;
          5 for(a=1,a<101,a=a+1)
          6 sum=sum+a;
          7 printf(“%d“,sum);
          8}
          1 #include<stdio.h>
          2 void main()
          3 {
          4  int a=100,sum=0;
          5  sum=((a+1)*a)/2;//數學公式
          6  printf("%d",sum);
          7 }
           1 main()
           2 {
           3  int sum,i;
           4  i=1;
           5  sum=0;
           6  while(i<=100)
           7  { 
           8   sum=sum+i;i++;
           9  }
          10  printf("sum=%d\n",sum);
          11 }
          posted on 2006-01-19 14:39 ★yesjoy★ 閱讀(802) 評論(0)  編輯  收藏 所屬分類: 算法總結
          主站蜘蛛池模板: 建昌县| 西吉县| 安岳县| 麦盖提县| 衡南县| 陇南市| 太谷县| 油尖旺区| 长治市| 马龙县| 南雄市| 鹤山市| 阳城县| 彭州市| 临安市| 桃园市| 德惠市| 贺州市| 林西县| 南岸区| 西丰县| 利川市| 宁陕县| 葵青区| 桐城市| 红安县| 息烽县| 夹江县| 灵山县| 洛扎县| 满洲里市| 佛山市| 东源县| 宜州市| 炎陵县| 静海县| 阳原县| 家居| 江北区| 九江县| 樟树市|