In: Computer Science
I need this in pseudocode:
Similar to the previous assignment, you’re going to read in the number of years the player played and the starting year of that player – followed by the statistics for those years. This time, however, you’re going to print out the years from worst to best in sorted order. Hint: this will require a second array to store years. If you can sort one array, can you sort both? Sample Output #1: Enter the number of years: 5
Enter the starting year: 2003
Enter stat for year 2003: 5
Enter stat for year 2004: 4
Enter stat for year 2005: 7
Enter stat for year 2006: 1
Enter stat for year 2007: 3
2006|2007|2004|2003|2005|
Sample Output #2: Enter the number of years: 6
Enter the starting year: 1879
Enter stat for year 1879: 70
Enter stat for year 1880: 89
Enter stat for year 1881: 111
Enter stat for year 1882: 65
Enter stat for year 1883: 105
Enter stat for year 1884: 98
1882|1879|1880|1884|1883|1881|
PseudoCode:
1.start
2.print "Enter number of years"
3. Read n
4.print "Enter starting year"
5.Read s
6.Declare two arrays of type integer
Declare original[n],sort[n]
7.Declare i,j,temp
8.Define j<-0,temp<-0
9.for i=s to s+n
BEGIN
print "Enter stat for year
",i
Read temp
original[j]<-temp
sort[j]<-temp
j<-j+1
END
10. Sort the array 'sort'
11. for i=0 to n
BEGIN
temp<-get index of sort[i] from
original[] array
print "temp+s"
print "|"
END
12.Stop
Screenshot:
The screenshot is attached for better understanding of indentations.