写一个蓝桥杯java求和的代码
时间: 2024-06-01 09:09:47 浏览: 52
蓝桥杯代码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int sum = 0;
for (int i = 1; i <= n; i++) {
sum += i;
}
System.out.println(sum);
}
}
阅读全文