C + + 5th time on-machine experiment: array separation

Source: Internet
Author: User

I. Questions and codes

/*02.* file name: Using the Loop summation 03.*    : Yuval 04.* Completion Date:  May  8th 05.* version number: v1.006.* Description of Task and Solution Method Section: 07.* Input Description: 08.* problem Description: Slightly 09.* program output: Odd even split 10.* problem analysis: Slightly 11.* algorithm design: The following 12.*/#include <iostream>using namespace Std;int main () {    const int n=10;     int b,i,k,j,l,a[10],b[10],c[10];     int o=0,p=0;     cout<< "Please enter 10 numbers" <<endl;     for (i=0;i<n;i++)       {cin>>b;          a[i]=b;}      for (k=0;k<n;k++)          {if (a[k]%2==0)             {c[o]=a[k];               o=o+1;}           else              {b[p]=a[k];p =p+1;}}      for (j=0;j<p;j++)         cout<<b[j]<< "";             cout<<endl;         for (l=0;l<o;l++)           cout<<c[l]<< "";              cout<<endl<< "Thank you for using this program";}


Two. Running results



Third, experience
Arrays are still not very skilled and need a lot of practice.


Iv. Summary of Knowledge points

Array use must first define the number of



C + + 5th time on-machine 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.