I. Questions and codes
/ * File name: C + + experiment 5* : Liu Yin * completion date: May 10, 2016 * Version number: v1.0 * Description of the task and solution method part: Separating odd and even numbers using an array * Enter a description: Enter any 10 number * Problem Description: My fifth C + + program, familiar with the meaning of the array and the use of * program output: Separate odd and even * problem analysis: Correctly save the number to a different array * algorithm design: Slightly * /#include <iostream.h>void main () { int A[10],b[10],c[10],i,j=0,k=0;for (i=0;i<10;i++) {cin>>a[i];if (a[i]%2==0) {b[j]=a[i];j++;} else {c[k]=a[i];k++;}} cout<<endl;cout<< "even is:"; for (i=0;i<j;i++) {cout<<b[i]<< "";} cout<<endl;cout<< "Odd is:"; for (i=0;i<k;i++) {cout<<c[i]<< "";} Cout<<endl;}
ii. Results of Operation
Third, experience
C + + in the use of arrays and understanding will be more abstract, especially with the front of the circular statement, many places will appear some difficult to solve problems, but through continuous learning and practice, finally better grasp the use of the array, but also finally succeeded in solving this problem, good practice will always succeed.
Iv. Summary of Knowledge points
There are many things to be particularly important in the array, such as the size of the array, the number of arrays, subscript, input, output, initialization, and so on, as long as the master of these basic points, I believe that the use of arrays is not too big, refueling!
C + + experiment 5