Fragments of 1049 and the number of columns, C

Explanations directory

#include <stdio.h>
int main()
{
	double sum=0.0,a[100001]={0};
	long int reserve=0,n,i=1;
	scanf("%ld",&n);
	reserve = n;

	while(i<=n)
	{
		scanf("%lf",&a[i]);
		i++;
	}

	i=1;
	while(i<=reserve)
	{
		sum += i*n*a[i];
		i++;
		n--;
	}
	printf("%.2f",sum);
	//system("pause");
	return 0;
}
Published 44 original articles · won praise 0 · Views 864

Guess you like

Origin blog.csdn.net/weixin_43916400/article/details/104615826