C + + experiment 5-array separation

Source: Internet
Author: User

I. Questions and codes

   /* File name: Array separator  *    Creator: Dragon late autumn * finish date: 20160505   * Version number: v1.0   * Description of task and solution method part:  * Input Description: None   * Problem Description: Enter 10 numbers from the keyboard in the array A, put the odd number in the array B, and even put in the array c after the output. * Program output: No   * problem analysis: slightly  * algorithm design: Slightly   *   /#include <iostream>using namespace Std;int main () {    const int n=10;    int a[n],b[n],c[n],i,j=0,k=0;    cout<< "Please enter 10 number:" <<endl;    for (I=0;i<n;++i)    {        cin>>a[i];        if (a[i]%2==0)        {            b[j]=a[i];            j + +;        }        else        {            c[k]=a[i];            k++;        }    }    cout<< "even array:";    for (i=0;i<j;i++)    cout<<b[i]<< "";    cout<<endl;    cout<< "odd array:";    for (i=0;i<k;i++)    cout<<c[i]<< "";    
two. Running Results


Three. Experience

This learning array is difficult, the main is that they do not have enough to do the problem at the time of more difficult, the process appeared in a number of errors, with the help of students to correct.

Four. Summary of Knowledge points

The use of array knowledge


C + + experiment 5-array separation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.