2.代码如下:
#include <iostream> using namespace std; int main(){ int num; cin>>num; int sum=0; while (num--!=0) { int input; cin>>input; if(input%2==0){ sum+=input; } } cout<<sum; return 0; }