	program magi2_93	! Magistere 2 annee 1992

	implicit none

	parameter	maxn=20

	integer	li,lc,lo,ll,i,inote,nn,ncand,k,in(maxn)
	real	n(100,maxn),c(maxn),tc,tnote,note,total
	real	mir(maxn),miv(maxn),mar(maxn),mav(maxn),d(maxn)
	character*60	fi,fo,fl
	character*33	nom(100)

	li=1
	lc=2
	lo=3
	ll=4

	fi='(a33,10i3)'
	fo='(1x,i3,11f5.1)'
	fl='(25x,i2,3x,a33)'

	open(li,name='magi2_93.not',type='old',readonly)
	open(lc,name='magi2_93.coe',type='old',readonly)
	open(lo,name='magi2_93.out',type='new')
	open(ll,name='magi2_93.net',type='new')

	tc=0
	i=0
	do while (.true.)
		i=i+1
c		write(6,'(a,i3,a)')'$2x(reel et voulu),coef,-1 ?'
		read (lc,*,end=9)mir(i),miv(i),mar(i),mav(i),c(i),d(i)
		tc=tc+c(i)
	end do
9	nn=i-1

	ncand=0
	do while (.true.)
		ncand=ncand+1
		read (li,fi,end=99)nom(ncand),(in(i),i=1,nn)
		do i=1,nn
			n(ncand,i)=float(in(i))
			if (n(ncand,i).lt.0) n(ncand,i)=d(i)
			n(ncand,i)=miv(i)
	1			+(n(ncand,i)-mir(i))*(mav(i)-miv(i))
	1				/(mar(i)-mir(i))
		end do
	end do
99	continue
	ncand=ncand-1

	tnote=0
	do k=1,ncand
		total=0
		do i=1,nn
			total=total+n(k,i)*c(i)
		end do

		note=total/tc
		tnote=tnote+note

		inote=ifix(note+0.5)
		write (lo,fo)inote,note,(n(k,i),i=1,nn)
		write (ll,fl)inote,nom(k)

	end do
	write(6,'(a,f7.2)')'   Moyenne generale :',tnote/ncand

	stop
	end
