题解 | #[NOIP2015]金币#
[NOIP2015]金币
https://www.nowcoder.com/practice/8f71f5670e6a45118d24d13868a2da9e
#include <stdio.h>
int main() {
int n = 0;
scanf("%d", &n);//输入天数
int a = 0;//带值所用
int length = 0;//计算天数
int total = 0;//计算金币总数
while (n > length)
{
int i = 1000;//定义一个数字用于循环
for (a = 1; a <= i; a++)
{
int j = 1;
for (j = 1; j <= a; j++)
{
total += a;
length++;
if (length == n)
{
break;
}
}
if (length == n)
{
break;
}
}
}
printf("%d\n", total);
return 0;
}
C语言基础 文章被收录于专栏
里面较为详细的介绍了c语言的相关用法和有关题目。

