题解 | #求 1 - n 之间偶数的和#
求 1 - n 之间偶数的和
https://www.nowcoder.com/practice/03df7fa0950046a9ba564b4438f918a3
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int sum = 0;
for (int i = 1; i <= n; i++) {
if(i%2==0) {
sum += i;
}
}
printf("%d",sum);
return 0;
}