Problem ID :g023. D.海加爾山之戰

New Thread

User why ??

stanleystanley SendIMessage
stanley

g023. D.海加爾山之戰 | From: 219.80.176.10 | Post Date:2017-11-24 18:31:31.0

#include <iostream>
using namespace std;

int main() {
  int n,sum=0,num;
  cin >> n;
  while (cin >> num) {
    if (num==0) {
      break;
    }
    else {
      sum+=num*num;
    }
  }
  cout << sum << endl;
}
 


文章類型: 一般 | Reply | Back
User Re:why ??

sagit SendIMessage
sagit

g023. D.海加爾山之戰 | From: 175.180.76.190 | Post Date:2017-11-24 23:32:10.0

sum歸零的動作要寫在 while 迴圈裡面 


文章類型: 一般 | Reply | Back

New Thread

ZeroJudge Forum