题解 | #牛牛的西格玛#
牛牛的西格玛
https://www.nowcoder.com/practice/c6b750ee8853484f8dbf14b9531b501f
#include <stdio.h> int main() { int n = 0; while (1 == scanf("%d", &n)) { int sum = 0; while (n) { sum += n; n--; } printf("%d\n", sum); } return 0; }
牛牛的西格玛
https://www.nowcoder.com/practice/c6b750ee8853484f8dbf14b9531b501f
#include <stdio.h> int main() { int n = 0; while (1 == scanf("%d", &n)) { int sum = 0; while (n) { sum += n; n--; } printf("%d\n", sum); } return 0; }
相关推荐