class test2{
public static void main(String[] args){
/*for (int i =1;i<=10 ;i++ ){
System.out.println(i);
}
System.out.println("---------------");
for (int i =10;i>=1 ;i-- ){
System.out.println(i);
}
*/
//1-10的和
int sum = 0;
for (int i = 1;i <= 10 ;i++ ) {
sum = sum + i;
}
System.out.println("sum = " + sum);
}
} |
|