输入12 9 7 18 3 11 20 0输出The sum of the odd numbers is 30.#include <stdio.h>int even(int n);int main(void){/* 此处添加程序 */}
1 回答
达令说
TA贡献1821条经验 获得超6个赞
int main(void)
{
cout<<"Please input numbers, end with 0: "<<endl;
int i = 0, sum = 0;
cin>>i;
while(i > 0)
{
if(i%2 != 0)
{
sum += i;
}
cin>>i;
}
cout<<"The sum of the odd numbers is "<<sum<<"."<<endl;
return 0;
}
- 1 回答
- 0 关注
- 123 浏览
添加回答
举报
0/150
提交
取消