第三道题目:
#include <iostream>
using namespace std;
main()
{
int no=0;
int ne=0;
int i;
int a[5]={1,2,3,4,5};
int o[5];
int e[5];
for(i=0;i<5;i++)
{
a[i]%2==1?o[no++]=a[i]:e[ne++]=a[i];
}
cout<<"the odd is:";
for(i=0;i<no;i++)
cout<<o[i]<<endl;
cout<<"the even is:";
for(i=0;i<ne;i++)
cout<<e[i]<<endl;
}
#include <iostream>
using namespace std;
main()
{
int no=0;
int ne=0;
int i;
int a[5]={1,2,3,4,5};
int o[5];
int e[5];
for(i=0;i<5;i++)
{
a[i]%2==1?o[no++]=a[i]:e[ne++]=a[i];
}
cout<<"the odd is:";
for(i=0;i<no;i++)
cout<<o[i]<<endl;
cout<<"the even is:";
for(i=0;i<ne;i++)
cout<<e[i]<<endl;
}