The number of briquettes in C language for the 7th Lanqiao Cup

【Problem Description】:
Number of briquettes

There is a pile of briquettes, piled up in a triangular pyramid shape. specific:
Put 1 on the first layer,
3 on the second layer (arranged in a triangle),
6 in the third layer (arranged in a triangle),
10 on the fourth layer (arranged in a triangle),
....
If there are 100 layers, how many briquettes are there?

Please fill in the number representing the total number of briquettes.
Note: Your submission should be an integer, do not fill in any superfluous content or descriptive text.



[Method ideas]: By reading the title, it is not difficult to find that, assuming that the 0th layer is 0 briquettes, each subsequent layer is the number of briquettes in the previous layer plus the layer number of this layer. For example: there are 6 briquettes in the third layer (3 in the second layer + 3 in this layer)



【Reference Code】:
 
 
#include<stdio.h>
#include<windows.h>

intmain()
{
	int line_count = 0;
	long long sum = 0;
	int i = 0;
	for(i = 1; i < 101; i++)
	{
		line_count = line_count + i;
		sum += line_count;
	}
	printf("sum=%d\n", sum);
	system("pause");
	return 0;
}


【operation result】:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325951207&siteId=291194637