/** file Name: Project 1: Array separator *: He Zezhi * Completed: May 2016 7 * version: v1.0* input Description: 10 integers * Problem Description: Enter 10 numbers from the keyboard in the array A, put the odd number in the array B, even In the array C and then output separately. * Program output: Array of odd and even * problem analysis: slightly * algorithm design: Slightly */#include <stdio.h> #include <iostream>using namespace Std;int main () { const int n = 10;int A[n], I, b[n] = {0}, C[n] = {0};for (i = 0; i<n; i++) B[i] = 1;for (i = 0; i<n; i++) {cin ;> a[i];if (a[i]% 2 = = 1) b[i] = a[i];if (A[i]% 2 = = 0) C[i] = A[i];} cout << "odd: \ n"; for (i = 0; i<n; i++) {if (b[i]! = 1) cout << b[i] << "";} cout << "\ n" << "even: \ n"; for (i = 0; i<n; i++) {if (c[i]! = 0) cout << c[i] << "";} cout << "\ n"; system ("pause"); return 0;}
/** file Name: Item 5: Array summation *: He Zezhi * Completion date: May 2016 8 * version: v1.0* input Description: 10 integers * Problem Description: Enter 10 numbers from the keyboard, respectively, to find the sum of integers and negative and * program output: Positive and , Negative and * problem analysis: slightly * algorithm design: Slightly */#include <stdio.h> #include <iostream> using namespace Std;int Main () {const int n = 10;int A[n], I, ZS = 0, fs = 0;for (int i = 0; i<10; i++) {cin >> a[i];if (a[i]> 0) zs=zs+a[i];elsefs=fs+a[i];} cout << "positive and:" << zs << endl;cout << "negative and:" << FS << endl;system ("pause"); return 0;}
C + + fifth time computer experiment--Project I, item five