(1)
Questions and codes
/* Copyright (c) 2014, Yantai University School of Computer * All rights reserved. * File name: Test.cpp *: Simbin * Completion date: November 24, 2014 * Version number: v1.0 * * Problem Description: Create an integer array with 20 elements, initialize, assign an initial value to the first 10 elements in the array, and then enter after 1 through the keyboard The value of 0 elements, from the value of the elements in the output array (from No. 0 to 19th), each of the 5 elements is wrapped in one line. * Enter a description: 10 elements. * Program output: sequential output; */#include <iostream>using namespace Std;int main () { int a[20]= { 102,60,46,453,435,54,4654,456,31,45}; Initializes the first 10 elements for (int i=10; i<=19; i++) cin>>a[i];//The value of the 10 elements after the keyboard input cout<< "by going after the values in the array are:" <<endl;//the value of all elements in the output array by going to (int n=0; n<=19; n++) { cout<<a[n]<< ""; if (n==4| | n==9| | n==14) cout<<endl; } return 0;}
Operation Result:
(2)
Questions and codes
/* Copyright (c) 2014, Yantai University School of Computer * All rights reserved. * File name: Test.cpp *: Simbin * Completion date: November 24, 2014 * Version number: v1.0 * * Problem Description: Creates an integer array of length 10 and initializes all the elements in the array from backward forward (from 9th element to No. 0 element direction) The value of the element, changing the value of the array elements, doubling all the data, and outputting the changed values. * Input Description: no input. * Program output: Reverse order output and doubling output; */#include <iostream>using namespace Std;int main () { int a[10]= { 102,60,46,453,435,54,4654,456,31,45}; Initializes the first 10 elements cout<< "by the forward, the value in the array is:" <<endl;//the value of all elements in the array after the forward output for (int n=9; n>=0; n--) cout <<a[n]<< ""; cout<<endl; cout<< "value after double:" <<endl; for (int n=9; n>=0; n--)//Make all data doubly cout<<2*a[n]<< ""; return 0;}
Operation Result:
(3)
Questions and codes
/* Copyright (c) 2014, Yantai University School of Computer * All rights reserved. * File name: Test.cpp *: Simbin * Completion date: November 24, 2014 * Version number: v1.0 * * Problem Description: Create an integer array of length 16 and initialize it, first output the number of multiples of the element value in the array of 3, and then output all subscript 3 The element value of the multiplier. * Input Description: no input. * Program output: The number of elements in the array is multiples of 3, outputting all element values with multiples of subscript 3; */#include <iostream>using namespace Std;int main () { int a[16]= { 13,45,89,332,54,221,90,723,65,45,123,47,96,48,187,}; Initialize cout<< "Array, the number of multiples of element value 3 is:" <<endl; for (int n=0; n<=15; n++) { if (a[n]%3==0&&a[n]!=0) cout<< "a[" <<n<< "]" < < "" <<a[n]<<endl; } cout<< "The element value for a multiplier of 3 is:" <<endl; for (int n=0; n<=15; n++) { if (n%3==0) cout<< "a[" <<n<< "]" << "" <<a[n ]<<endl; } return 0;}
Operation Result:
13th Week on-machine practice project--the big toss of the array