C + + Fifth experiment--array separation

Source: Internet
Author: User

I. Questions and codes


/* File name:  Array Separator *    by:    Liang Zhou * completion date:  5   months  * Version number: v1.0 * Description of task and solution method part:   process Sequence using an array * input description:  Enter 10 number * Problem Description:   Detach It * program output:  odd-even separation * problem analysis: * Algorithm design: * *  #include <iostream>using namespace Std;int Main () {const int n=10;inta[n],b[n],c[n],i,j=0,k=0;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<< "odd array:";        for (i=0;i<k;i++) cout<<c[i]<< ","; return 0;}

Two. Running results



Three. Experience

Feeling C + + is becoming more and more difficult, it may be a talent problem, it always feels magical, but I still need to spend a lot of time on it to write my homework.


Four. Summary of Knowledge points

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.