Programa média ponderada de notas
Ler as 2 notas do aluno: N1, N2
Calcular a média ponderada do aluno
media = ( N1 + 4*N2) / 5
Weighted average program from 0 ~ 20 notes
Read 2 student grades: N1, N2
Calculate the weighted average student
final score = (N1 + N2 * 4) / 5
Programme moyen pondéré de 0 ~ 20 notes
Lire 2 notes des étudiants: N1, N2
Calculer l'étudiant moyen pondéré
score final = (N1 + N2 * 4) / 5
org 1000h
N1: ds 1
N2: ds 1
org 3000h
start: lda N1
mov b,a ; the N1 we save at the b register
lda N2
add a ; here accumulator=2*N2
add a ; here we have accumulator 4*N2
add b ; in the accumulator we have N1+4*N2
add a ; lets two multiply all by 2 and then we must divide by 10
; accumulator have now 2(N1+4*N2).
; lets go to divide the accumulator by 10
mvi c,0 ; we use the register c to count the times that we
; subtract the accumulator by 10
mvi d,10 ; we use d register to made the subtraction as sub d
loop: cpi 10 ; to see if accumulator is less then 10, if carry then a<10
jc theend
sub d ; its equal to do sui 10, note d is 10 but less expensive time
inr c
jmp loop
theend: rst 1 ; the media is at: the integer part at c regist
; and decimal part at the acumulator
end ;
EN: Blog with various topics utilities (and curiosities) in various fields: mathematics, electricity, electronics, physics, programming, crafts... PT: Blog com temas diversos com utilidades (e também curiosidades ) em vários domínios: matematica, electricidade, electrónica, fisica, programação, trabalhos manuais... FR: Blog avec de "choses" utiles (et curiosités) dans divers domaines: mathématiques, l'électricité, l'électronique, la physique, de la programmation, de l'artisanat...
Sem comentários:
Enviar um comentário