Package 002;
import Java.util.Scanner;//used to scan data from a specified string
public class a{
public static void Main (String[]args) {
Int[] arr1={-2574,-4010,8243,771,2447,-5197,2556,8044,3314,3617,6065,-2817,3131,6318,2186,-113,629,2582,-37,- 1520,164,2055,-5936,5912,1717,5988,4781,5757,892,-4394,8034,2213,-1080,-2080,5364,106,2657,566,3940,- 5116,4583,1806,6555,2621,7197,528,1626,18,1049,6243,3198,4397,-1325,9087,936,-6291,662,-178,135,-3473,-2385,- 165,1713,-7949,-4234,1138,2212,104,6968,-3632,3801,1137,-1296,-1215,4272,6223,-5922,-7723,7044,-2938,- 8180,1356,1159,-4022,-3713,1158,-8715,-4081,-2541,-2555,-2284,461,940,6604,-3631,3802,-2037,-4354,-1213,767};/ /I think it's most intuitive to copy the data
int sum=0;
for (int i=1;i<=100;i++)
{
Sum+=ai;
}
System.out.println ("Start");
int Start=nextint ();
System.out.println ("End");
int end=nextint;
System.out.println (start=start+);
System.out.println (end=end+);
for (int i=start;i<=end;i++);/* This side uses Start/end to do subscript (Start/end is its own definition, you can take the range of the array according to the start/end, like Starta20,enda66, You can implement the sum of A20 to A66 */
Sum+=ai;
SYSTEM.OUT.PRINTLN (sum);
}
Package 002;
public class B {
public static void Main (String[]args) {
int[][]a={{-2574,-4010,8243,771,2447,-5197,2556,8044,3314,3617,6065,-2817,3131,6318,2186,-113,629,-2582, -37,-1520,164,2055,-5936,5912,1717,5988,4781,5757,892,-4394,8034,2213,-1080,-2080,5364,106,2657,566,3940,- 5116,4583,1806,6555,2621,-7197,528,1626,18,1049,6243,3198,4397,-1325,9087,936,-6291,662,-178,135,-3473,-2385,- 165,1713,-7949,-4234,1138,2212,104,6968,-3632,3801,1137,-1296,-1215,4272,6223,-5922,-7723,7044,-2938,- 8180,1356,1159,-4022,-3713,1158,-8715,-4081,-2541,-2555,-2284,461,940,6604,-3631,3802,-2037,-4354,-1213,767},{ 2740,-4182,-5632,-2966,-1953,567,-8570,1046,2211,1572,-2503,-1899,3183,-6187,3330,3492,-464,- 2104,316,8136,470,50,466,-1424,5809,2131,6418,-3018,6002,-8379,1433,1144,2124,1624,-602,-5518,5872,870,-5175,- 3961,-427,-6284,2850,481,6175,141,-766,-1897,-748,-4248,366,4823,3003,1778,3256,2182,2253,5076,5540,-2650,2451 , -1875,5482,-6881,-329,-969,-8032,-2093,612,1524,-5492,5758,-7401,-5039,3241,6338,3581,4321,- 1072,4942,2131,210,-7045,-7514,7450,-1142,-2666,-4485,-639,2121,-5298,-3805,-1686,-2520,-1680,2321,-4617,-1961,2076,7309}};;/ /define a two-dimensional array is an example of a two-dimensional array in the book of reference to the Java EE Basic Tutorial
A=new int[100][];//initialization A is an array of length 100, an array element of a array is a reference class
int sum=0;
for (int i=0;i<a.length;i++)
for (int j=0;j<a.length;j++)
SUM+=A[I][J]
{
System.out.println (A[i][j]);
}
A[0]=new int[2];//initializes the first element of a array
a[0][1]=6;//accesses the second array of index groups of the first element of the A array
The first element of the for (int i=0;i<a[0].length;i++)//a array is a one-dimensional array that iterates through the one-dimensional array
{
SYSTEM.OUT.PRINTLN (sum);
}
Package 002;
public static void Main (String[]args)
{
int sum=0;
Int[][][] A =
{
{{ -2574,-4010,8243,771,2447,-5197,2556,8044,3314,3617,6065,-2817,3131,6318,2186,-113,629,-2582,-37,- 1520,164,2055,-5936,5912,1717,5988,4781,5757,892,-4394,8034,2213,-1080,-2080,5364,106,2657,566,3940,- 5116,4583,1806,6555,2621,-7197,528,1626,18,1049,6243,3198,4397,-1325,9087,936,-6291,662,-178,135,-3473,-2385,- 165,1713,-7949,-4234,1138,2212,104,6968,-3632,3801,1137,-1296,-1215,4272,6223,-5922,-7723,7044,-2938,- 8180,1356,1159,-4022,-3713,1158,-8715,-4081,-2541,-2555,-2284,461,940,6604,-3631,3802,-2037,-4354,-1213,767}},
{{2740,-4182,-5632,-2966,-1953,567,-8570,1046,2211,1572,-2503,-1899,3183,-6187,3330,3492,-464,- 2104,316,8136,470,50,466,-1424,5809,2131,6418,-3018,6002,-8379,1433,1144,2124,1624,-602,-5518,5872,870,-5175,- 3961,-427,-6284,2850,481,6175,141,-766,-1897,-748,-4248,366,4823,3003,1778,3256,2182,2253,5076,5540,-2650,2451 , -1875,5482,-6881,-329,-969,-8032,-2093,612,1524,-5492,5758,-7401,-5039,3241,6338,3581,4321,- 1072,4942,2131,210,-7045,-7514,7450,-1142,-2666,-4485,-639,2121,-5298,-3805,-1686,-2520,-1680,2321,-4617,- 1961,2076,7309}},
{{302,-7944,-6551,6648,-884,-6332,1188,-248,3902,-2171,-3782,-3510,6203,-636,-4605,4497,3187,-6278,1198,- 7963,7647,-3022,-8267,7995,-1998,-4171,730,-8117,-1706,7601,-2454,-6161,-1810,243,-2841,- 5377,2985,2328,177,5622,3596,3057,2830,-1151,6566,2254,6972,-3060,4063,367,84,3156,3880,-1530,5272,1385,-565,- 1736,1267,-3863,-229,2072,2423,-7449,9555,2844,-1278,-3613,-919,4153,-4232,4032,-5732,199,4792,2498,-3344,- 4193,2650,-579,3416,-3575,1822,-6936,-2661,-1873,414,2314,6844,7613,-7844,6680,5974,2208,-3597,6302,4396,-141, -1864,1939}}
};//the definition of a three-dimensional array is the same as two-dimensional
int A=new int[100][][];//Initialization A is an array of length 100, an element of a array, or a reference class
int sum=0;
for (int i=0;i<a.length;i++)
for (int j=o;j<a.length;j++)
for (int q=o;q<a.length;q++)
SUM+=A[I][J][Q];
A[0]=new int[2];//initializes the first element of a array
a[0][1]=6;//accesses the second array of index groups of the first element of the A array
for (int i=0;i<a[0].length;i++)
{
SYSTEM.OUT.PRINTLN (sum);
SYSTEM.OUT.PRINTLN (sum);
}
Experience and Summary:
I think it's easy to see the topic, is not to achieve 100 numbers, 200 numbers, 300 numbers add it, then asked a few students, they are to achieve hundreds of numbers added, but also no simple. The teacher gave the excle table has thousands of numbers, we want to achieve any range of hundreds of numbers added. So I was worried, suddenly lost the clue. For the addition of hundreds of numbers in any range, that is when writing code to the number of tags, but there are so many numbers, you can not always add a label, dozens of hundreds of numbers may be labeled, but like this thousands of tens of thousands of so many how to add Ah, and add the number is not only one-dimensional, There are two and three dimensions. Do not know how to achieve, so I asked Jerrick classmate, he said I can make a fuss in the for loop, I can arbitrarily replace the initial value and the final value, and then try to use start and end to replace the For Loop 1 and. I finished the first one-dimensional array, and found that this method is very useful, but in the back of the two and three-dimensional array I do not want me to use this, so I went to the last semester of the Java EE book to look at the array of the view of the time to find in the processing of two-dimensional array, You can use a two-dimensional array as a one-dimensional array to traverse each element in a two-bit array. So I'm dealing with any of the 200 numbers on the two-dimensional array, referring to an example in the book, but I have modified it, unfortunately, my tomcat and my eclipse have broken down, not testing, unloading the reload several times also not. But I know my code should be some problems, the foundation is not very good, not perfect. But I'm going to do a two-and three-dimensional array of one-dimensional arrays after the sum of any range, and it's relatively straightforward to find the code of two-and three-dimensional arrays that are analogous to the code of an array.
There is every time the software engineering project, will force me to see the content before learning, warm so know new, harvest a lot!
Personal Project Practice