Lab Test 1 Make-up (Red Test)

 

加選同學五題全做,上次考試不到30分同學任選三題作答。

 

1.1.        Read in 20 integers into an array, find the smallest element and print it out.

1.2.        Read in 20 integers into an array, find the smallest element and swap it with the first element in the array. Then swap the smallest element in the remaining 19 elements with the second element in the array. Repeat this in a loop to sort the entire array. Print out the array after each swapping.

1.3.        Write a program to print out the following 9 x 9 pattern:

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

*

 

 

*

 

 

 

 

 

*

 

 

 

 

*

 

 

 

*

 

 

 

 

 

 

*

 

*

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

*

 

*

 

 

 

 

 

 

*

 

 

 

*

 

 

 

 

*

 

 

 

 

 

*

 

 

*

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

1.4.        Write a program to print out the following 9 x 9 pattern:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

*

*

*

*

 

 

 

 

*

*

*

*

*

 

 

 

 

*

*

*

*

*

 

 

 

 

*

*

*

*

*

 

 

 

 

*

*

*

*

*

 

 

 

 

 

 

*

*

*

*

*

 

 

 

 

 

 

*

*

*

*

*

 

 

 

 

 

 

*

*

*

*

*

 

 

 

 

 

 

*

*

*

*

*

 

 

 

 

 

 

 

 

 

 

1.5.        Write a program to print out the following 9 x 9 pattern:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

*

*

*

*

 

 

 

 

*

 

 

 

*

 

 

 

 

*

 

 

 

*

 

 

 

 

*

 

 

 

*

 

 

 

 

*

 

 

 

*

 

 

 

 

 

 

*

 

 

 

*

 

 

 

 

 

 

*

 

 

 

*

 

 

 

 

 

 

*

 

 

 

*

 

 

 

 

 

 

*

*

*

*

*