输入n个数,输出其中所有奇数的乘积?程序咋写?

学习 时间:2026-08-14 07:02:48 阅读:5125
输入n个数,输出其中所有奇数的乘积?程序咋写?

最佳回答

冷酷的糖豆

自由的帽子

2026-08-14 07:02:48

#include <stdio。h>int main(){    int n;    int x;    int i;    int ans = 1;    scanf("%d",&n);    for (i=0;i<n;i++)    {            scanf("%d",&x);         if( x%2==1 ) ans = ans*x;    }    printf("%d\n",ans);    return 0;}

最新回答共有2条回答

  • 单身的歌曲
    回复
    2026-08-14 07:02:48

    #include <stdio。h>int main(){    int n;    int x;    int i;    int ans = 1;    scanf("%d",&n);    for (i=0;i<n;i++)    {            scanf("%d",&x);         if( x%2==1 ) ans = ans*x;    }    printf("%d\n",ans);    return 0;}

上一篇 Please make a list of places----tourists to go to in shangha

下一篇 初中生英语手抄报版面设计图