C语言题目:1-10奇数相乘

C语言题目:1-10奇数相乘
还有1-10偶数相乘

#include <stdio.h>
void main()
{
int i,s=1;
for(i=1;i<10;i+=2)
s*=i;
printf("奇数乘积为:%d\n",s);
s=1;
for(i=2;i<=10;i+=2)
s*=i;
printf("偶数乘积为:%d\n",s);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-06-11
这个还需要编程???
#include <stdio.h>
int main()
{
printf("1到10奇数相乘:%d\n",1*3*5*7*9);
return 0;
}
第2个回答  2009-06-11
#include <stdio.h>
int main()
{
int s=1;
int i;
for(i=1; i<=10; i++)
if(i%2==1) //i is odd
s=s*i;

printf("%d\n",s);
return 0;
}

用我楼上的方法.. 他的好.

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网