Questions and codes
/* for : Liang * Completion Date: May 8, 2016 * Version number: v1.0 * Description of the task and solution method part: * Input Description: No * Problem Description: Enter 10 numbers from the keyboard in the array A, The odd number in the array is placed in array B, and the even number is placed in the array C and then output separately. * Program output: 10 number of odd and even * problem analysis: * Algorithm Design: * /#include <iostream>using namespace Std;int main () {int a[10],b[10],c[ 10],j=0,k=0;cout<< "Enter 10 integers, separated by spaces" <<endl;for (int i=0;i<10;i++) cin>>a[i];for (i=0;i<10;i+ +) {if (a[i]%2!=0) b[j]=a[i],j++;elsec[k]=a[i],k++;} cout<< "Odd number:" <<endl;for (i=0;i<j;i++) cout<<b[i]<< "";cout<<endl;cout<< "even have "<<endl;for (i=0;i<k;i++) cout<<c[i]<<" "; return 0;
Run results
Experience: Changed for a long time, the operation has appeared random number, and then slowly try to finally fix
C + + experiment 5 Project 1: Array separation