#include <stdio.h>
#include <stdlib.h>
int main()
{
int a;
int b = 0;
int c;
int d[100] = {NULL};
int i;
int sum = 0;
if (scanf ("%d", &a) != EOF)
{
while (b < a)
{
scanf ("%d", &c);
d[b] = c;
b++;
}
}
for (i = 0; i < b; i++)
{
sum += d[i] * d[i];
}
printf ("%d\n", sum);
return 0;
}
#include
#include
int main()
{
int a;
int b = 0;
int c;
int d[100] = {NULL};
int i;
int sum = 0;
if (scanf ("%d", &a) != EOF)
{
while (b < a)
{
scanf ("%d", &c);
d[b] = c;
b++;
}
}
for (i = 0; i < b; i++)
{
sum += d[i] * d[i];
}
printf ("%d\n", sum);
return 0;
}
第i天賣i元
應該是sum += (i + 1) * d[i] 吧