C + + Fifth experiment--array separation

Source: Internet
Author: User

I. Questions and codes

 file name: array separation * AS By: Liu Jia Material * completion date: May 10, 2016 * Version number: v1.0 * Description of Task and solution Method section: Using Arrays and for language * Input Description: Enter 10 integers * problem description: Separate odd and even * program output: Even Group C is      : 2 4 6 8 0 Odd Group B is: 1 3 5 7 9* Problem analysis: Using array * Algorithm design: For statement if statement #include <iostream.h> void 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 C is:"; for (j=0;j<n-k;j++) {cout<<c[j]<< "";         cout<<endl;            } cout<< "Odd Group B is:"; for (k=0;k<n-j;k++) {cout<<b[k]<< "";            cout<<endl; }    }  

Two. Running results


Three. Experience:

Actually not very will do this, fortunately, today the teacher explained a bit, on the copy down, a back on the write up, afraid to forget

Four. Summary of Knowledge points:

Utilize the FOR statement, if statement, to utilize the array

C + + Fifth 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.