First, Questions and Codes
/** file name: array separation. cpp* : Cong * Completion date: May 8 * Version number: v1.0* Description of the task and solution method part: * Input Description: Enter 10 integers * Problem Description: Slightly * program output: Output 1 respectively 0 odd and even numbers in the number; * Problem analysis: Isolating array output, using variable for different use * algorithm design: For statement and array combination, and if Else statement to judge */#include <iostream>using namespace std; int main () {int a[10],b[10],c[10],i,j=0,k=0; cout<< "Please enter an integer of 10 array A:" <<endl; for (i=0;i<10;i++) { cout << "a[" <<i<< "]="; cin>>a[i]; } for (i=0;i<10;i++) { if (a[i]%2!=0) { j + +; B[j]=a[i]; } else { k++; C[k]=a[i]; } } cout<< "Array B:"; for (i=1;i<=j;i++) cout<< "b[" <<i<< "]=" <<b[i]<< "\ T"; cout<< "\ n" << "array C:"; for (i=1;i<=k;i++) cout<< "c[" <<i<< "]=" <<c[i]<< "\ T"; return 0;}
Ii. Results of operation
Third, experience
The first attempt to use the array to write a program, wrote a long time, the emergence of a variety of problems, 1.1 points with cout output debugging program, 1.1 points to solve the problem, finally understand how to better operate, this program is a little complicated, but I do not want to change, leave a memorial it.
Iv. Summary of Knowledge points
Array input and output should be organized, not using the unknown variable output, pay special attention to the array of each number corresponding to the location.
C + + 5th time on-machine experiment-array separation