Tip: After the article is written, the table of contents can be automatically generated. How to generate it can refer to the help document on the right
Article Directory
foreword
1. Steps to use
1. Read in data
Add data from one to one hundred: 1+2+3+4+5+...+99+100;
2. The code is as follows (example):
public class class1 {
/*
*
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a;
double sum=0;
for(a=1;a<101;++a) {
sum+=a;
}
System.out.println("sum="+sum);
}
}
运行截图为:
![在这里插入图片描述](https://img-blog.csdnimg.cn/2bae6bd9c5dc45e3a5d56249ed748341.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBASVTlsI_nkKo=,size_20,color_FFFFFF,t_70,g_se,x_16)
# 总结
例如:利用循环来求和。