Added Fortran.

This commit is contained in:
Nicolás A. Ortega 2017-04-03 14:28:46 +02:00
parent 88cee02522
commit 9c22b0905e
No known key found for this signature in database
GPG Key ID: 3D786FB3123FF1DD
2 changed files with 46 additions and 1 deletions

View File

@ -24,6 +24,7 @@
CC=gcc CC=gcc
CXX=g++ CXX=g++
JAVAC=javac JAVAC=javac
FTR=gfortran
# Other commands # Other commands
RM=rm -rf RM=rm -rf
@ -31,7 +32,7 @@ RM=rm -rf
# Directories # Directories
BINDIR=bin BINDIR=bin
all: c cpp java all: c cpp fortran java
c: c:
mkdir -p $(BINDIR) mkdir -p $(BINDIR)
@ -41,6 +42,10 @@ cpp:
mkdir -p $(BINDIR) mkdir -p $(BINDIR)
$(CXX) src/Main.cpp -o $(BINDIR)/doublesgame-cpp $(CXX) src/Main.cpp -o $(BINDIR)/doublesgame-cpp
fortran:
mkdir -p $(BINDIR)
$(FTR) src/main.f -o $(BINDIR)/doublesgame-f
java: java:
mkdir -p $(BINDIR) mkdir -p $(BINDIR)
$(JAVAC) src/DoublesGame.java -d $(BINDIR) $(JAVAC) src/DoublesGame.java -d $(BINDIR)

40
src/main.f Normal file
View File

@ -0,0 +1,40 @@
C Copyright (C) 2017 Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net> All rights reserved.
C Author: Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
C
C This software is provided 'as-is', without any express or implied
C warranty. In no event will the authors be held liable for any damages
C arising from the use of this software.
C
C Permission is granted to anyone to use this software for any purpose,
C including commercial applications, and to alter it and redistribute it
C freely, subject to the following restrictions:
C
C 1. The origin of this software must not be misrepresented; you must not
C claim that you wrote the original software. If you use this software
C in a product, an acknowledgment in the product documentation would be
C appreciated but is not required.
C
C 2. Altered source versions must be plainly marked as such, and must not be
C misrepresented as being the original software.
C
C 3. This notice may not be removed or altered from any source
C distribution.
program doublesgame
integer :: a,n = 1
logical :: run = .TRUE.
do while(run)
write(*,*) '2^', n, '='
read(*,*) a
if(a .EQ. 0) then
write(*,*) "Goodbye!"
run = .FALSE.
elseif(a .NE. 2 ** n) then
write(*,*) "Wrong answer, try again."
else
write(*,*) "Correct!"
n = n + 1
endif
enddo
end program doublesgame