Programming Activity 8.4

屏幕快照 2017-06-12 下午8.38.27

Line89, we fill the arr[i] array with 31 random numbers.

屏幕快照 2017-06-12 下午8.42.44


屏幕快照 2017-06-12 下午8.38.36

Use for loop to go through all elements in arr[i] array and print every element out.

屏幕快照 2017-06-12 下午8.43.00


屏幕快照 2017-06-12 下午8.38.41

Set the value of all elements in arr[i] array to be int value.

屏幕快照 2017-06-12 下午8.45.20.png


屏幕快照 2017-06-12 下午8.38.49

I input a value. The for loop check the value of all elements inside the array, whenever the value is same as the inputted value, count will plus 1.

屏幕快照 2017-06-12 下午8.47.55.png


屏幕快照 2017-06-12 下午8.53.46.png

I first set the minimum to be the first number in the array. Then I compare all the other elements in the array with the value of minimum. If one element’s value is less, then the minimum value, the value of that element will be set to the minimum.

屏幕快照 2017-06-12 下午8.53.36

Real-life Application & Conclusion

This algorithm can be developed to process more complicated data and have more functions like rank the data, calculate the sum, mean, or standard deviation. By adding GUI to the algorithm, the algorithm becomes more user-friendly and accessible leading to broader implications.

 

 

 

留下评论