#24928: C++ 同時輸入運算


perfect1021 (完美主義)

學校 : 高雄市私立復華高級中學
編號 : 151042
來源 : [1.200.88.190]
最後登入時間 :
2021-04-06 08:32:20
a693. 吞食天地 | From: [1.200.88.190] | 發表日期 : 2021-04-06 08:19

int n,m;

    while(cin>>n>>m){

        int table[n+1],temp;

        table[0]=0;

        for(int i=0;i<n;i++){

            cin>>temp;

            table[i+1]=table[i]+temp;

        }

        while(m--){

            int a,b;

            cin>>a>>b;

            cout<<table[b]-table[a-1]<<endl;

        }

    }

 
ZeroJudge Forum