MCPcopy Create free account
hub / github.com/DuGuQiuBai/Java / main

Method main

day21/code/java/ForTest3.java:2–42  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

1class ForTest3 {
2 public static void main(String[] args) {
3 //���1-100֮��ż����
4
5 /*
6 //������ͱ���
7 int sum = 0;
8
9 //ͨ��forѭ����ȡÿһ������
10 for(int x=1; x<=100; x++) {
11 //�������ۼ�
12 sum += x;
13 }
14
15 //������
16 System.out.println("1-100֮�ͣ�"+sum);
17 System.out.println("---------------");
18 */
19
20 //ż��:�ܱ�2����������
21 //����ж������Ƿ��ܹ���������? x%2 == 0
22
23 /*
24 int sum = 0;
25
26 for(int x=1; x<=100; x++) {
27 if(x%2 == 0) {
28 sum += x;
29 }
30 }
31
32 System.out.println("1-100��ż���ͣ�"+sum);
33 */
34
35 int sum = 0;
36
37 for(int x=0; x<=100; x+=2) {
38 sum += x;
39 }
40
41 System.out.println("1-100��ż���ͣ�"+sum);
42 }
43}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected