	program magiesbs

	implicit none

	parameter	maxn=50

	integer	li,lo,i,inote,nn,ncand
	real	n(maxn),c(maxn),tc,tnote,note,total
	character*60	fi,fo
	character*14	nom

	li=1
	lo=2

	fi='(a14,f7.2,f7.2,f7.2,f7.2,f7.2,f7.2,f7.2,i5)'
	fo='(a14,f7.2,f7.2,f7.2,f7.2,f7.2,f7.2,f7.2,i5)'

	open(1,name='magiesbs.not',type='old',readonly)

	tc=0
	i=0
	do while (.true.)
		i=i+1
		write(6,'(a,i3,a)')'$coefficient ',i,' :'
		read (5,*,end=9)c(i)
		tc=tc+c(i)
	end do
9	nn=i-1


	tnote=0
	ncand=0
	do while (.true.)

		read (li,fi,end=99)nom,(n(i),i=1,nn)
		ncand=ncand+1
		total=0
		do i=1,nn
			total=total+n(i)*c(i)
		end do

		note=total/tc
		tnote=tnote+note

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

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

	stop
	end
