added old projects
This commit is contained in:
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"java.project.sourcePaths": ["src"],
|
||||
"java.project.outputPath": "bin"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
## Getting Started
|
||||
|
||||
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||
|
||||
## Folder Structure
|
||||
|
||||
The workspace contains two folders by default, where:
|
||||
|
||||
- `src`: the folder to maintain sources
|
||||
- `lib`: the folder to maintain dependencies
|
||||
|
||||
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
|
||||
|
||||
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
|
||||
|
||||
## Dependency Management
|
||||
|
||||
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,48 @@
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Random;
|
||||
|
||||
public class Aray {
|
||||
//Returns the indexof the minimum value in the array.
|
||||
public static int findMin(int[] a) {
|
||||
int min = 101;
|
||||
int length = a.length;
|
||||
int index = 0;
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (a[i] < min)
|
||||
min = a[i];
|
||||
index = i;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//Returns the indexof the maximum value in the array.
|
||||
public static int findMax(int[] a) {
|
||||
int max = 0;
|
||||
int length = a.length;
|
||||
int index = 0;
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (a[i] > max)
|
||||
max = a[i];
|
||||
index = i;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
//Returns the statistical mean of the values in the array.
|
||||
public static double mean (int[] a) {
|
||||
int sum = 0;
|
||||
int length = a.length;
|
||||
for (int i = 0; i < length; ++i) {
|
||||
sum += a[i];
|
||||
}
|
||||
return sum / length;
|
||||
}
|
||||
|
||||
//Populates the array with a series of integer values between 0 and 100 (inclusive) that are randomly generated.
|
||||
public static void populate(int[] a) {
|
||||
Random rnd = new Random();
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
a[i] = rnd.nextInt(0, 101);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
public class Tester {
|
||||
public static void main(String[] args) throws Exception {
|
||||
//data_type name = new data_type ;
|
||||
int[] a = new int[100] ;
|
||||
Aray.populate(a);
|
||||
System.out.println("Max: " + Aray.findMax(a));
|
||||
System.out.println("Min: " + Aray.findMin(a));
|
||||
System.out.println("Mean: " + Aray.mean(a));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user