Askisi 1 !Ypologismos athroismatos S=1+2+3+4+5 program sum implicit none integer:: i,S S=0 do i=1,5 S=S+i end do print*,’S=1+2+3+4+5=’,S end program sum
Askisi 2 !Ypologismos athroismatos S=1+2+3+4+5+…+n program sum implicit none integer:: i,S,n print*,”dwse to n” read*,n S=0 do i=1,n S=S+i end do print*,’S=1+2+3+4+5+…+n=’,S end program sum
Askisi 3 !Ypologismos athroismatos S=1+3+5+7+9+11 program sum implicit none integer::i,S S=0 do i=1,11,2 S=S+i end do print*,’S=1+3+5+7+9+11’,S end program sum
Askisi 4 !Ypologismos athroismatos perittwn S=1+3+5+7+9+11+…n program sum implicit none integer::i,S,n print*,”dwse to n” read*,n S=0 do i=1,n,2 S=S+i end do print*,’S=1+3+5+…n’,S end program sum
Askisi 5 !Ypologismos athroismatos S=2+4+6+8+10+12 program sum implicit none integer::i,S S=0 do i=2,12,2 S=S+i end do print*,’S=2+4+6+8+10+12 print*,’S=2+4+6+8+10+12’,S ’,S end program sum Askisi 6 !Ypologismos athroismatos artiwn S=2+4+6+8+10+12+…n S=2+4+6+8+10+12+…n program sum implicit none integer::i,S,n print*,”dwse to n” read*,n S=0 do i=2,n,2 S=S+i end do print*,’S=2+4+6+…+n’,S end program sum
Askisi 7 !Ypologismos athroismatos S=1+1/2+1/3+1/4+1/5 program sum implicit none integer::i real::S S=0 do i=1,5 S=S+1.0/i end do print*, “S=1+1/2+1/3+1/4+1/5=”,S end program sum Askisi 8 !Ypologismos athroismatos S=1+1/2+1/3+1/4+1/5+…+1/n program sum implicit none integer::i,n real::S print*,”dwse to n” read*,n S=0 do i=1,n S=S+1.0/i end do print*, “S=1+1/2+1/3+1/4+1/5+…+1/n”,S end program sum
Askisi 9 !Ypologismos athroismatos S=1+22+32+42+52+…+1002 program sum implicit none integer::i,S S=0 do i=1,100 S=S+i**2 end do print*, “S=”,S end program sum
Askisi 10 !Ypologismos athroismatos S=1+22+32+42+52+…+n2 program sum implicit none integer::i,n,S print*,”dwse to n” read*,n S=0 do i=1,n S=S+i**2 end do print*, “S=”,S end program sum
Askisi 11 !Ypologismos athroismatos S=1+1/22+1/32+1/42+1/52+…+1/1002 program sum implicit none integer::i real::S S=0 do i=1,100 S=S+(1/i**2) end do print*, “S=”,S end program sum Askisi 12 !Ypologismos athroismatos S=1+1/22+1/32+1/42+1/52+…+1/n2 program sum implicit none integer::i,n real::S print*,”dwse to n” read*,n S=0 do i=1,n S=S+(1/i**2) end do print*, “S=”,S end program sum
Askisi 13 !Ypologismos athroismatos S=1+(1+1/2)2+(1+1/3)2+… program sum implicit none integer::i,n real::S print*,”dwse to n” read*,n S=0 do i=1,n S=S+(1+1/i)**2 end do print*, “S=”,S end program sum Askisi 14 !Ypologismos athroismatos S=1+(1+1/2)+(1+1/2+1/3)+…+(1+1/2+1/3+…1/n) program sum implicit none integer::i,j,n real::S,S1 print*,”dwse to n” read*,n S=0 do i=1,n S1=0 do j=1,i S1=S1+1.0/j end do S=S+S1 end do print*, “S=”,S end program sum
Askisi 15 !Ypologismos athroismatos S=1+(1+1/2)+(1+1/2+1/22)+…+(1+1/2+1/22+…1/2n) program sum implicit none integer::i,j,n real::S,S1 print*,”dwse to n” read*,n S=1 do i=1,n S1=0 do j=1,i S1=S1+1.0/2**j end do S=S+S1 end do print*, “S=”,S end program sum
Askisi 16 !Ypologismos athroismatos S=x+x/2+x/3+x/4+x/5+…+x/n program sum implicit none integer::i,x,n real::S print*,”diavase to x” read*,x print*,”dwse to n” read*,n S=0 do i=1,n S=S+x/i end do print*, “S=”,S end program sum
Askisi 17 !Ypologismos athroismatos olws twn arithmwn apo to -10 ews to 5 me bhma 2 kai ystera me bhma 0,5 program sum implicit none integer:: i,S S=0 do i=-10,5,2 S=S+i end do print*,’S=’,S end program sum
program sum implicit none real:: i,S S=0 do i=-10,5,0.5 S=S+i end do print*,’S=’,S end program sum
Askisi 18 !Eyresh max 2 arithmwn program sigrisi implicit none real::x,y,max print*,”diavase ta x,y” read*,x,y if (x>y) max=x max=y print*,max end program sigrisi
Askisi 19 !Ypologismos ths ax+b=0 Program prwtobathmia implicit none real::a,b,x print*.”diavase to a” read*,a print*,”diavase to b” read b if (a==0) then if (b==0) then print*,”h eksiswsh einai aoristh” else print*,”h eksiswsh einai adynath” end if else x=-b/a print*,”h eksiswsh exei monadikh lush x=”,x end program prwtobathmia
Askisi 20 !Ypologismos ths ax2+bx+c=0 program deyterovathmia implicit none real::a,b,c,x,x1,x2,D print*.”diavase to a” read*,a print*,”diavase to b” read*,b print*,”diavase to c” read*,c if (a==0) then if (b==0) then if (c==0) then print*,”h eksiswsh einai aoristh” else print*,”h eksiswsh einai adynath” end if else x=-c/b print*,”h eksiswsh exei monadikh lush x=”,x end if else D=b**2-4*a*c print*,”D=”,D if (D<0) then print*, “h eksiswsh den exei pragmatikes rizes” else if (D==0) then x=-b/(2*a) print*,” h eksiswsh exei diplh riza thn x=”,x else x1=(-b+sqrt(D))/2*a x2=(-b-sqrt(D))/2*a print*,”h eksiswsh exei duo rizes x1=, x2=”,x1,x2 end if end if end program deyterobathmia
Askisi 21 !eyresh min kai max apo 10 pragmatikous arithmous program minmax implicit none real::min,max real,dimension(10)::a integer::i print*,”dwse ta stoixeia tou a” do i=1,10 read*,a(i) end do max=a(1) min=a(1) do i=2,10 if (a(i)>=max) then max=a(i) else if (a(i)<=min) then min=a(i) end if end do print*,”max=”,max print*,”min=”,min end program minmax
Askisi 22 !eyresh min kai max apo n pragmatikous arithmous program minmax implicit none real::min,max integer::i,n real,dimension(:),allocatable::a print*,”dwse th diastash tou a” read*,n allocate(a(n)) print*,”dwse ta stoixeia tou a” do i=1,n read*,a(i) end do max=a(1) min=a(1) do i=2,n if (a(i)>=max) then max=a(i) else if (a(i)<=min) then
min=a(i) end if end do print*,”max=”,max print*,”min=”,min deallocate(a) end program minmax
Askisi 23 !Programma pou kaneis taksinomisi 100 onomatwn kata ayksousa seira program sorting implicit none integer, parameter:: nmax=100 !dilwnw genika th diastash enos array me thn parameter ! character,dimension(nmax)::name character:: help integer::i,j,n print*,”diavase th diastash” ! twn arithmo twn onomatwn pou thelw na taksinomhsw! read*,n print*,”diavase ta onomata” read*,( name(i), i=1,n) ! prepei to n na einai mikrotero apo to nmax! do i=1,n-1 do=i+1,n if (name(i)>name(j)) then help= name(i) name(i)=name(j) name(j)=help end if end do end do print*,”ta onomata kata alfavitiki seira einai”, (name(i),i=1,n) end program sorting
Askisi 24 !Ypologismos athroismatos n tyxaiwn arithmwn program sum implicit none real,dimension(:),allocatable::x integer::i,n real::S print*,”diavase th diastash” read*,n allocate(x(n)) do i=1,n print*,”x(“,i,”)” read*,x(i) end do S=0.0 do i=1,n S=S+x(i) end do print*,”S=”,S deallocate(x) end program sum
Askisi 25 !Ypologismos ixnous tetragwnikou pinaka A program trace implicit none real,dimension(:,:),allocatable::A integer::i,j,n real::trace print*,”diavase th diastash” read*,n allocate(A(n,n)) print*,”diavase ton pinaka A” do i=1,n do j=1,n print*,”diavase ta stoixeia tou A” read*,A(i,j) end do end do trace=0.0 do i=1,n trace=trace+A(i,i) end do print*,”trace=”,trace
deallocate(A) end program trace
Askisi 26 !Ypologismos athroismatos antistrofwn stoixeiwn enos monodiastatou array( dianysmatos) program sum implicit none integer::n,i real::S integer,parameter::nmax=10 real,dimension(nmax)::A print*,”dwse th diastash tou dianusmatos” read*,n print*,”dwse ta stoixeia tou dianusmatos” do i=1,n read*,A(i) end do S=0 do i=1,n S=S+1/A(i) end do print*,”S=”,S end program sum
Askisi 27 !Prosthesi duo dianusmatwn a,b program sum implicit none real,dimension(:),allocatable::a,b,c integer::i,n print*,”dwse th diastash twn dianusmatwn” read*,n allocate (a(n),b(n),c(n)) print*,”dwse ta stoixeia tou dianusmatos a” do i=1,n read*,a(i) end do do i=1,n read*,b(i) end do do i=1,n c(i)=a(i)+b(i) end do print*,”c=” do i=1,n print*,c(i) end do deallocate (a,b,c) end program sum
Askisi 28 !Ginomeno duo dianusmatwn a,b program ginomeno implicit none real,dimension(:),allocatable::a,b integer::i,n real::prod print*,”dwse th diastash twn dianusmatwn” read*,n !elegxos egkurothtas dedomenwn do while (n<0) print*,”to n prepei na einai thetikos arithmos” read*,n end do allocate (a(n)) allocate(b(n)) print*,”dwse ta stoixeia tou dianusmatos a” do i=1,n read*,a(i) end do do i=1,n read*,b(i) end do prod=0 do i=1,n prod=prod+a(i)*b(i) end do print*,”prod=”,prod deallocate(a) deallocate(b) end program ginomeno
Askisi 29 !Ypologismos mesou orou program mesosoros implicit none real,dimension(:),allocatable::x integer::i,n real::mo,S print*,”dwse th diastash” read*,n allocate(x(n)) do i=1,n print*,”x(“,i,”)” read*,x(i) end do S=0.0 do i=1,n S=S+x(i) end do mo=S/n print*,”mo=”,mo deallocate(x) end program mesosoros
Askisi 30 !Programa pou ektypwnei aristera tous artious kai deksia toys perittous program artioi_perittoi implicit none integer,dimension(:),allocatable::X,A,P integer::i,n,artioi,peritoi,k print*,:dwse ti diastash” read*,n allocate(X(n),A(n),P(n)) print*,”diavase to dianisma X” do i=1,n print*,”diavase ta stoixeia tou X”,i read*,X(i) end do artioi=0 perittoi=0 do i=1,n if(mod(X(i),2)==0) then artioi=artioi+1 A(artioi)=X(i) else Perittoi=perittoi+1 P(perittoi)=X(i) end if end do if (artioi>perittoi) then k=artioi else k=perittoi end if print*,”artioi” do i=1,k if (i<=artioi) then print*,A(i) end if if(i<=perittoi) then if (i>artioi) then print*,P(i) else print*,P(i) end if end if end do deallocate(X,A,P) end program artioi_perittoi
Askisi 31 !Prosthesi duo pinakwn A,B program sum implicit none integer,dimension(:,:),allocatable::A,B,C integer::i,j,n print*,”dwse th diastash twn pinakwn” read*,n allocate (A(n,n),B(n,n),C(n,n)) print*,”diavase ton A” do i=1,n do j=1,n read*,A(i,j) end do end do print*,”diavase ton B” do i=1,n do j=1,n read*,B(i,j) end do end do do i=1,n do j=1,n C(i,j)=A(i,j)+B(i,j) end do end do print*,”C=”,C do i=1,n print*,(C(i,j),j=1,n) end do deallocate (A,B,C) end program sum
Askisi 32 Ginomeno duo pinakwn A,B program ginomeno implicit none integer,dimension(:,:),allocatable::A,B,C integer::i,j,k,m,r,n print*,”dwse th diastash twn pinakwn” read*,m,r,n allocate (A(m,r),B(r,n),C(m,n)) print*,”diavase ton A” read*,((A(i,j),j=1,r),i=1,m) print*,”diavase ton B” read*,((B(i,j),j=1,n),i=1,r) do i=1,m do j=1,n C(i,j)=0 do k=1,r C(i,j)=C(i,j)+A(I,k)*B(k,j) end do end do end do print*,”C=A*B”,C do i=1,m print*,(C(i,j),j=1,n) end do deallocate (A,B,C) end program ginomeno
Askisi 33 !Ypologismos athroismatos stoixeiwn kathe grammhs enos pinaka program athroismagrammwn implicit none real,dimension(:,:),allocatable::A real,dimension(:),allocatable::B print*,”diavase th diastash tou pianka A” read*,n allocate(A(n,n),B(n)) print*,”diavase ta stoixeia tou A” do i=1,n do j=1,n read*,A(i,j) end do end do print*,”o pinakas A einai” do i=1,n print*,(A(i,j),j=1,n) end do do i=1,n B(i)=0 do j=1,n B(i)=B(i)+A(i,j) end do end do print*,”to dianisma einai”,(B(i),i=1,n) deallocate (A,B) end program athroismagrammwn
Askisi 34 !Ypologismos n! me xrhsh function program paragontiko implicit none integer::n,prod print*,”diavase to n” read*,n print*,”n!=”,prod(n) end program paragontiko integer function prod(n) implicit none integer::n,i if (n==0) then prod =1 else prod =1 do i=1,n prod=prod*i end do end if end function prod Askisi 35 !Ypologismos ths f(x)=3*x+1 me xrhsh function program sinartisi implicit none real::x real::f do x=0,100,10 print*,”gia x=”,x,” “,”f(x)=”,f(x) end do end program sinartisi real function f(x) implicit none real::x f=3*x+1 end function f
Askisi 36 !Ypologismos ths f(x)=1-√ kai f(x)=1+√ me xrhsh function program sinartisi implicit none real::x real::f print*,”diavase to x” read*,x print*,”f(x)=”,f(x) end program sinartisi real function f(x) implicit none real::x if (x>0) then f=1-sqrt(1+x**2) else if (x<0) then f=1+sqrt(1+x**2) end if end function f Askisi 37 !Ypologismos ths f(x)=1-√ , f(x)=0 gia x=0 kai f(x)=1+√ me xrhsh function program sinartisi implicit none real::x real::f print*,”diavase to x” read*,x print*,”f(x)=”,f(x) end program sinartisi real function f(x) implicit none real::x if (x>0) then f=1-sqrt(1+x**2) else if (x<0) then f=1+sqrt(1+x**2) else f=0 end if end function f
Askisi 38 !Ypologismos sunthetou klasmatos
α1+
program suntheto_klasma implicit none real::func1 real,dimension(100)::A integer::n,i real::y print*,”diabase th diastash” read*,n print*,”dwse ta stoixeia” do i=1,n read*,A(i) end do y=func1(A,n) print*,”I timi ths sunartisis einai”,y end program sunteto_klasma real function func1(A,n) implicit none real,dimension(100)::A integer::I,n func1=A(n) do i=n,2,-1 func1=A(i-1)+1./func1 end do return end function func1
Askisi 39 !Anathesi stoixeiwn pinaka se dianusma kai sorting kata ayksousa kai kata fthinousa seira me xrhsh uporoutinas program sorting implicit none real,dimension(;,:),allocatable::A real,dimension(:),allocatable::S integer::i,j,n print*,”diavase ti diastash tou pinaka” read*,n allocate(A(n,n),S(n)) print*,”diavase ta stoixeia tou pinaka” do i=1,n do j=1,n read*,A(i,j) end do end do do i=1,n S(i)=A(i,i) end do print*,(S(i),i=1,n) call sort(S,n) print*,”to dianusma meta th taksinomisi einai”,(S(i),i=1,n) deallocate (A,S) end program sorting !kata ayskousa seira! subroutine sort(X,n) implicit none integer::n,i,j real,dimension(n)::X real::help do i=1,n-1 do j=i+1,n if (X(i)>X(j)) then help=X(i) X(i)=X(j) X(j)=help end if end do end do end subroutine sort !kata fthinousa seira! subroutine sort(X,n) implicit none
integer::n,i,j real,dimension(n)::X real::help do i=1,n-1 do j=i+1,n if (X(i)
Askisi 40 !programma pou upologizei to athroisma twn grammwn enos pinaka kai vriskei to max apo ayta program addmax real,dimension(:,:),allocatable::A real,dimension(:),allocatable::S integer::i,j,n real::max print*,”diavase th diastash tou pinaka A” read*,n allocate(A(n,n),S(n)) print*,”diavase ta stoixeia tou A kata grammh” do i=1,n do j=1,n read*,A(i,j) end do end do call sumrow(A,S,n) do i=1,n print*,S(i) end do call maximum(max,S,n) print*,”max=”,max end program addmax subroutine sumrow(A,S,n) integer::n,i,j real,dimension(n,n)::A real,dimension(n)::S do i=1,n S(i)=0 do j=1,n S(i)=S(i)+A(i,j) end do end do end subroutine sumrow subroutine maximum(max,S,n) integer::n,i real,dimension(n)::S real::max max=S(1) do i=2,n if (max
end do end subroutine maximum
Askisi 41 !Dunami pinaka program power implicit none integer::n,m,i,j,k,p real,dimension(:,:)::A,B,pow print*,”diavase ti diastash” read*,n allocate(A(n,n)) print*, “diabase ta stoixeia tou A ” do i=1,n do j-1,n read*,A(i,j) end do end do print*,”diavase ti dinamh” read*,m allocate(B(n,n)) allocate (pow(n,n)) B=A do p=1,m-1 do i=1,n do j=1,n pow(i,j)=0 do k=1,n pow(i,j)=pow(i,j)+A(i,k)*B(k,j) end do end do end do B=pow end do pow=B print*,”h dunamh tou pianaka A einai “,m do i=1,n do j=1,n print*,B(i,j) end do end do deallocate(A) deallocate(B) deallocate(pow) end program power