C + + 5th experiment-Array separation

Source: Internet
Author: User

I. Questions and codes

/** file Name: array separation *    Creator: * Completion date:  5   months  8  Days * Version number: v1.0* Description of task and solution method part: Use an array and a for language * to enter a description: 
    input 10 Integers * problem Description: Odd  number and even * program output:  Even the Group A is: 12 24 36 78 Array B is: 13 5 67 89 9 19* Problem analysis:  using array * algorithm design: For  statement if statement */ #include <iostream>using namespace Std;int main () {    const int n=10;    int a[n],c[n],b[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)        {           c[j]=a[i];           j + +;        }        else        {            b[k]=a[i];            k++;        }    }             cout<< "Even group A is:";          for (j=0;j<n-k;j++)         {             cout<<c[j]<< "";         }             cout<< "Odd Group B is:";          for (k=0;k<n-j;k++)            {             cout<<b[k]<< "";            }  return 0;}

Ii. Results of operation


Third, experience

Pay attention to the range of loops when using the For statement.

Iv. Summary of Knowledge points

The use of arrays makes input data simple and easier to read.

C + + 5th experiment-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.