C + + experiment 5-array separation

Source: Internet
Author: User

I. Questions and codes

/** file Name: C + + experiment 5*    : Chen Guanxin * Completion date:     2016     May    8th * Version number: v1.0* Description of task and solution method part: Array separation * Input Description: * Problem Description: Enter 10 numbers in the array from the keyboard A, the odd number in the array is placed in array B, the even number is placed in the array C and then output separately. * Program Output: * 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;}
Second, operation and results


Third, experience

Feeling array This chapter is difficult to understand, it also requires me to slowly digest

Iv. Summary of Knowledge points

One-dimensional arrays

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.