C + + experiment 5-array separation

Source: Internet
Author: User

I. Questions and codes

  /* File name: 0510.cpp *    Creator:  liuqing Rain * Completion Date:  May 10  * Version number: v1.0  * Description of task and solution method part: Using array to split odd even; * input Description: Enter 10 numbers; * Problem Description: 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. * Program output: Output the odd and even numbers in the array respectively; * Problem analysis: Judging parity and classifying it; * Algorithm design: Slightly */#include <iostream>using namespace Std;int main () {int a[10],b[1 0],c[10],m=0,n=0,k=0,j=0,i; cout<< "Please enter 10 number:"; for (i=0;i<=9;i++) {cin>>a[i];if (a[i]%2!=0) b[m++]=a[i],k++;elsec[n++]=a[i],j++;} if (k>0) {cout<< "odd group:"; for (m=0;m<k;m++) cout<<b[m]<< "" <<endl;} else cout<< "No odd number in this group" <<endl;if (j>0) {cout<< "even group:"; for (n=0;n<j;n++) cout<<c[n]< < "" <<ENDL; else cout<< "No odd number in this group" <<endl;return 0;}

ii. Results of Operation


Iii. Summary of Knowledge points

How to handle various array problems

Iv. Experience

Rigorous, careful, reduce the error rate in the process


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.