Line | |
---|
1 | module pal
|
---|
2 | implicit none
|
---|
3 |
|
---|
4 | public :: anna
|
---|
5 |
|
---|
6 | contains
|
---|
7 |
|
---|
8 | function anna (strng) result (jein)
|
---|
9 | character(len=*),intent(in) :: strng
|
---|
10 | logical :: jein
|
---|
11 | character(len=1),dimension(len(strng)) :: feld
|
---|
12 | integer :: i,n
|
---|
13 |
|
---|
14 | n = len(strng)
|
---|
15 |
|
---|
16 | do i=1,n
|
---|
17 | feld(i) = strng(i:i)
|
---|
18 | end do
|
---|
19 |
|
---|
20 | i = n/2
|
---|
21 | if(all(feld(:i) == feld(n:n+1-i:-1))) then
|
---|
22 | jein=.true.
|
---|
23 | else
|
---|
24 | jein=.false.
|
---|
25 | end if
|
---|
26 |
|
---|
27 | end function anna
|
---|
28 | end module pal
|
---|
29 |
|
---|
30 | program otto
|
---|
31 | use pal
|
---|
32 | implicit none
|
---|
33 | character(len=*),parameter :: palin="retter"
|
---|
34 | logical :: heyho
|
---|
35 |
|
---|
36 | heyho=anna(palin)
|
---|
37 | if (heyho) then
|
---|
38 | write(unit=*,fmt=*) "JAWOHL!"
|
---|
39 | else
|
---|
40 | write(unit=*,fmt=*) "NOE!"
|
---|
41 | end if
|
---|
42 | end program otto
|
---|
Note:
See
TracBrowser
for help on using the repository browser.