One. Questions and codes
/ * file name: 111111.cpp * Creator: Can andi remember * completion date: 2016 month 8th * Version number: v1.0 * Description of the task and solution Method Section: * Input Description: None * Problem Description: Enter 10 numbers from the keyboard into the array A, the sum of the positive and negative numbers in the a array. * Program output: "The sum of positive and negative numbers in a array" * Problem analysis: slightly * algorithm design: Slightly */ #include <iostream> using namespace std; void Main () {double X=0,y=0;int a[10],n;cout<< "Please enter any 10 numbers:"; for (n=0;n<10;n++) {cin>>a[n];if (A[n] >0) x+=a[n];elsey+=a[n];} cout<< "Positive sum is:" <<x<<endl;cout<< "negative sum is:" <<Y<<ENDL;}
Two. Run results
Three. Experience
The program of the array is difficult to understand, after the class to write more about the array of programs to achieve proficiency in the effect.
Four. Summary of Knowledge points
When writing array problems, n or I are generally good starting from 0, and when grouping sums, remember that the condition is clear to avoid affecting the whole program's operation because of the condition error.
C + + experiment 5: Summation