• Java学习的第三十八天


    例3.4.

    package bgio;
    public class cjava {
    public static void main(String[]args) {
    int i=1;
    int sum=0;
    while(i<=100) {
        sum=sum+i;
        i++;
    }
    System.out.println("sum"+sum);
    }
    }

     例3.5

    package bgio;
    public class cjava {
    public static void main(String[]args) {
    int i=1;
    int sum=0;
    do {
        sum=sum+i;
        i++;
    }while(i<=100);
    System.out.println("sum"+sum);
    }
    }

     例3.6

    package bgio;
    public class cjava {
    public static void main(String[]args) {
    int s=1;
    double n=1,t=1,pi=0;
    while((Math.abs(t))>(1e-7))
            {
        pi=pi+t;
        n=n+2;
        s=-s;
        t=s/n;
            }
    pi=pi*4;
    System.out.println("pi="+pi);
    }
    }

     2.数学方法不太知道.

    3.明天继续写例题

  • 相关阅读:
    java源码--ArrayList
    java源码--AbstractList
    java中public protected friendly private作用域
    设置springmvc全局异常
    Java
    Java
    Java
    Java
    Java
    Java
  • 原文地址:https://www.cnblogs.com/feng747/p/13498707.html
Copyright © 2020-2023  润新知