Fifth time on-machine experiment

Source: Internet
Author: User

One.

* File name: Project an array separation
* Author: Lai poetry
* Completion Date: May 10, 2016
* Version Number: v1.0
* Description of the task and solution: Enter 10 numbers from the keyboard in the array A, put the odd number in the array B, the even in the array c, and then output separately.
* Input Description: Enter 10 integers
* Description of the problem: odd and even numbers
* Program output: odd and even groups
* Problem Analysis:
* Algorithm design: For loop statement, array A[i], double branch SELECT statement.
*/

Two.

#include <iostream>using namespace Std;int main () {int a[10],b[10],c[10],i,n=0,j=0;cout<< "Please enter 10 numbers:"; for ( i=0;i<10;i++) cin>>a[i];for (i=0;i<10;i++) if (a[i]%2==0) {b[n]=a[i];n++;} else{c[j]=a[i];j++;} cout<< "Even group is:", for (i=0;i<n;i++) cout<<b[i]<< "";cout<<endl;cout<< "odd Group is:"; for (i=0 ; i<j;i++) cout<<c[i]<< ""; Cout<<endl;return 0;}


Three. Experience

1. The program was a success.

2. Although the later more study, but as long as the class to listen carefully, after-school review, homework every time carefully completed, to the back to learn also easy.

Four. Summary of Knowledge points

1. The input and output of the array must be in a circular statement.

2. Even if you do not know the number of array of numbers can also first make this array large enough, and then use I,n,j lai count.


Fifth time on-machine experiment

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.