I was given an assignment for class (new class just started a week ago) for fortran.
I've done some reading on fortran and get the general syntax but had a question of what the "best" way to go about this would be.
here's the inquery:
"Write a program in Fortran that (1) reads in an integer n, (2) computes the sine of 1, 2, ..., n (in degrees), generating n floats, (3) inserts those n floats, one at a time, into an ordered doubly-linked list, then (4) prints the contents of the list in reverse order.
You may assume that n is less than 10,000. You must compute the sine values by using these relations:
sin (1) = 0.017452406437284
cos (1) = 0.999847695156391
sin (a + b) = sin (a) cos (b) + cos (a) sin (b)
cos (a + b) = cos (a) cos (b) - sin (a) sin (b)
By an ordered doubly-linked list I mean a list with nodes having pointers both to the next and the previous node, and with a dummy head node, ordered so that following the "next" pointers leads to non-decreasing values of the sines."
Problem is...I thought you couldn't do pointers in fortran?
either way I assume my best bet would be to create 3 linked lists? one to insert them. then sort, then insert the sorted list into another and reverse it?
Sorry I wish I had more ideas but i have never used a language like fortran before? so any ideas?
thanks
I've done some reading on fortran and get the general syntax but had a question of what the "best" way to go about this would be.
here's the inquery:
"Write a program in Fortran that (1) reads in an integer n, (2) computes the sine of 1, 2, ..., n (in degrees), generating n floats, (3) inserts those n floats, one at a time, into an ordered doubly-linked list, then (4) prints the contents of the list in reverse order.
You may assume that n is less than 10,000. You must compute the sine values by using these relations:
sin (1) = 0.017452406437284
cos (1) = 0.999847695156391
sin (a + b) = sin (a) cos (b) + cos (a) sin (b)
cos (a + b) = cos (a) cos (b) - sin (a) sin (b)
By an ordered doubly-linked list I mean a list with nodes having pointers both to the next and the previous node, and with a dummy head node, ordered so that following the "next" pointers leads to non-decreasing values of the sines."
Problem is...I thought you couldn't do pointers in fortran?
either way I assume my best bet would be to create 3 linked lists? one to insert them. then sort, then insert the sorted list into another and reverse it?
Sorry I wish I had more ideas but i have never used a language like fortran before? so any ideas?
thanks