C + + experiment 5-array separation

Source: Internet
Author: User

I. Questions and codes

/* File name: Enter 10 numbers from the keyboard in the array A, put the odd number in the array B, the even number is in the array c, respectively output *    : Zou Peng Hui  * Date of Completion: May 8, 2016 * version number: v1.0 * Description of the task and solution Method Section: * Input Description:  * Problem Description: * Program output:  * Problem Analysis: * Algorithm design: * *  #include <iostream>  using namespace std;  int main () {const int n=10;int a[n],i=0,j=0,k=0;cout<< "Please enter 10 number:" <<endl;for (i=0;i<n;i++) {cin>>a[ I];} cout<< "is an even number with" <<endl;for (j=0;j<n;j++) if (a[j]%2==0) {cout<<a[j]<< "";} cout<<endl;    cout<< "is an odd number with" <<endl;for (k=0;k<n;k++) if (a[k]%2!==0) {cout<<a[k]<< "";}}


Ii. Results of operation


Third, experience

In the C + + language, you must first make an array of type descriptions before using the array

Iv. Summary of Knowledge points

The subscript of an array is written in square brackets after the array name, and the index of the element is counted from 0, incremented by 1 each time

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.