Permalink
Browse files

4-28-12

  • Loading branch information...
Brad Brad
Brad authored and Brad committed Apr 29, 2012
1 parent abf2cdc commit f8089c76e744e64fde1a745a561ac9bb665b803f
Showing with 63 additions and 3 deletions.
  1. +4 −3 prob11.f90
  2. +25 −0 prob12.f90
  3. +34 −0 prob13.f90
View
@@ -1,6 +1,7 @@
Program problem11
Implicit Integer (Selected_Int_Kind(16)) (I-N)
-Integer (Selected_Int_Kind(16)) :: numbers(1:20,1:20), nhorizontal(1:20,1:17), nvertical(1:17,1:20), ndiaganolr(1:17,1:17), ndiaganoll(1:17,4:20)
+Integer (Selected_Int_Kind(16)) :: numbers(1:20,1:20), nhorizontal(1:20,1:17), nvertical(1:17,1:20)
+Integer (Selected_Int_Kind(16)) :: ndiaganoll(1:17,4:20), ndiaganolr(1:17,1:17)
LUIN = 1
Open (LUIN,File='prob11numbers.txt',Status='OLD')
Do i = 1, 20
@@ -70,8 +71,8 @@ Program problem11
If ( mult > nANS) nANS = mult
End Do
End Do
-Do i = 4, 20
- Write ( LUOUT, * ) ndiaganoll(i,1:17)
+Do i = 1, 17
+ Write ( LUOUT, * ) ndiaganoll(i,4:20)
End Do
Write ( LUOUT, * ) 'Answer after diaganolleft',nANS
Write ( LUOUT, * ) 'Max diaganol',maxval(ndiaganoll(1:17,4:20))
View
@@ -0,0 +1,25 @@
+Program problem12
+nend = 500
+I = 0
+num = 0
+Do
+ I = I + 1
+ num = num+I
+ ndiv = 0
+ j = 0
+ nstop = num
+ Do
+ j = j+1
+ If ( j >= nstop ) Exit
+ If ( mod(num,j) == 0 ) Then
+ ndiv = ndiv+2
+ nstop = num/j
+ End If
+ End Do
+ Print *, num,'has',ndiv,'divisors'
+ If ( ndiv > nend ) Then
+ Print *, 'First triangle to have more than',nend,'divisors is',num
+ Exit
+ End If
+End Do
+End Program problem12
View
@@ -0,0 +1,34 @@
+Program problem13
+Integer :: num(1:100,1:50), nsum(1:100)
+Character (len=50) :: cnum(1:100)
+LUIN = 1
+Open (LUIN,File='prob13num.txt',Status='OLD')
+Do i = 1, 100
+ Read ( LUIN , '(A50)' ) cnum(i)
+End Do
+!Do i = 1, 100
+! Print *, cnum(i)
+!End Do
+Do i = 1, 100
+ Do j = 1,50
+ Read ( cnum(i)(j:j) , '(I1)' ) num(i,51-j)
+ End Do
+End Do
+!Do i = 1, 100
+! Print '(50I1)', num(i,50:1:-1)
+!End Do
+nsum(:) = 0
+Do i = 1, 100
+ Do j = 1,50
+ nsum(j) = nsum(j)+num(i,j)
+ Do k = 1, 99
+ If ( nsum(k) > 9 ) Then
+ nsum(k) = nsum(k)-10
+ nsum(k+1) = nsum(k+1)+1
+ End If
+ End Do
+ End Do
+End Do
+Print *, 'Sum of Numbers is'
+Print '(100I1)', nsum(100:1:-1)
+End Program problem13

0 comments on commit f8089c7

Please sign in to comment.