求C++程序,对一个一维数组,输出它的第奇数个或者第偶数个

2024-12-27 09:47:24
推荐回答(3个)
回答1:

float A[]={-9.85 -10.19 -10.6 -10.74...};
int b,c;
count<<"输如你要找第几个的数"<cin>>b;
if(b%2==1)
{
c=b/2+1
cout<<"你要找的是奇数是"<cout<<"它是第"<elso
{
c=b/2
cout<<"你要找的是偶数"<cout<<"它是第"<}

回答2:

#include
void main()
{
double a[100]={-9.85,-10.19,-10.6,-10.74,-10.85,-10.79,
-10.88,-10.92,-11.25,-11.3,-11.1,-11.29,-9.71,
-9.12,-8.69,-7.76,-7.95,-8.45,-7.91,-8.49,-8.34,
-8.95,-8.76,-8.68,-8.53,-7.77,-8.73,-8.49,-8.46,
-7.8,-8.46,-8.6,-8.53,-8.34,-8.38,-8.27,-8.17,
-8.09,-8.04,-8.04,-7.89,-7.72,-7.51,-7.55,-7.65,
-7.64,-7.65,-7.69};
// 输出偶数个数据
for(int i=0;i<48;i+=2)
{
printf("%g\t",a[i]);
}
printf("\n");
// 输出奇数个数据
for(int i=1;i<48;i+=2)
{
printf("%g\t",a[i]);
}
printf("\n");
}

回答3:

第奇数个是什么意思??????
~~~~~~~~~~~~~~~~~~~~