#24239: 簡單算法


u910088@shsh.tw (李秉蓒)

School : No School
ID : 138747
IP address : [123.205.87.22]
Last Login :
2021-04-19 20:08:50
b294. 經濟大恐荒 -- 板橋高中教學題 | From: [123.205.98.23] | Post Date : 2021-01-29 21:08

#include <stdio.h>

#include <stdlib.h>

int main(int argc, char *argv[]) {

int n,i,a,sum=0; 

scanf("%d",&n);

for(i=1;i<=n;i++){

scanf("%d",&a);

sum=sum+a*i;

}

printf("%d",sum);

return 0;

}

 
ZeroJudge Forum