输入八个数,求偶数之和:
#include<iostream>
using namespace std;
int func(int a)
{ if(a%2==0) return a; else return 0;
}
int main()
{ int a,b,c,d,e,f,g,h; cout<<"输入八个数:"; cin>>a>>b>>c>>d>>e>>f>>g>>h; int sum; sum=func(a)+func(b)+func(c)+func(d)+func(e)+func(f)+func(g)+func(h); cout<<"偶数之和为:"<<sum<<endl; return 0;