Saturday, June 20, 2015

[Programming book Chapter Eleven] array once again.

Do you remember writing programs for teachers of mathematics? The array of programs that we wrote three students out of the total number of tests for mathematics. If you do not mind, take a look at the program. We had a number of tests in a temporary array, the temporary array to another test number, the number of final exams is another array, and an array of the total number - have used a total of four arrays. So now the whole school is to write programs for the diagnosis of the results, but all the students of the class of the array to be used for testing all of the trouble of going to work. Lyanguyejei multi-dimensional array, so almost all the programming arrangements. So far, we've used the array, the array had all the dynamism. The program is now a little different way we write, using a single array. Let's say for the time being to reduce trouble in class ten students. I am writing to their numbers in the table below: Roll: 1 Roll: 2 Roll: 3 Roll: 4 Roll: 5 Roll: 6 Roll: 7 Roll: 8 Roll: 9 Roll: 10 First terminal exam 80 70 92 78 58 83 85 66 99 81 Second terminal exam 75 67 55 100 91 84 79 61 90 97 Final exam 98 67 75 89 81 83 80 90 88 77 Total marks Total Marks row of empty houses, because they have not yet calculated. First Term Examination 25%, 25% the second periodic testing and final exams will have to find 50% of the total number by adding the numbers. Now, on to our table to keep their numbers were 4 rows (row) and column 10. The programs we have written before, the first for an array of rows, one for the second row, third row and fourth in a row for the use of an array. Now I use a 2-D array (two-dimensional arrays). 2-D array to declare the rule is: data_type array_name [number of rows] [number of columns]; If it marks the upper chakata want to keep a 2-D array, but would write: int marks [4] [10]; Now, in the first row of the array of the marks [0], the second row marks [1], the third row marks [2] and the fourth row marks [3]. The marks [0] [0] is the first column of the first row, marks [0] [1] the first row of the second column, marks [0] [5] The first row of the sixth column, marks [1] [0] is the first column of the second row, marks [2] [3] is the fourth column of the third row. I hope, understand. Now tell me, which roll number 10 on the periodic testing of its second number is a house? The marks [0] [0] into the car and there is no test number? marks [0] [0] - 1 in the roll number of the first periodic examination and marks [1] [9] - will roll in the number of 10-second periodic testing. Thus, we can keep the array numbers: int marks [4] [10] = {{80, 70, 92, 78, 58, 83, 85, 66, 99, 81}, {75, 67, 55, 100, 91, 84, 79, 61, 90 , 97}, {98, 67, 75, 89, 81, 83, 80, 90, 88, 77}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; Here you have noticed that we actually have an array of arrays in four dynamism. marks [0] in the first frame on the number of examinations, marks [1] - the second periodic testing numbers, marks [2] - The number of final exams and marks [3] on the total number (since it is still not calculated, so the 0 I write).

No comments:

Post a Comment