terça-feira, 29 de dezembro de 2015

PT: programa que pede numeros inteiros ao utilizador
      enquanto numero diferente de zero e coloca depois ao terminar,
      no terminal a soma dos numeros introduzidos.

EN: program that asks the user to integers.
       When number entered is zero, the program terminates.  

       It appears in the terminal the sum of input numbers.

FR: programme qui demande à l'utilisateur de nombres entiers.
       Lorsque le numéro entré est zéro, le programme se termine

       Il apparaît dans le terminal la somme des nombres d'entrée.




The  Output of the program



The text of the Program

program soma;

uses crt;
var value,total : integer;

begin
    total:=0;
    writeln;
    writeln;
    writeln;
    writeln('PT: Escreva numeros inteiros, termine com 0');
    writeln('EN: Write integer numbers, write 0 to the end');
    writeln('FR: Ecrivez de numero entiere. mettre 0 pour finir');
    repeat
       read(value);
       total:=total+value;
    until value=0;
    writeln;
    writeln('PT: A soma dos valores introduzidos é ',total);
    writeln('EN: The sum of the numbers is ',total);
    writeln('FR: La adition de ces numeros est ',total);
end.


sábado, 21 de novembro de 2015

EN: Program c++ to calculate the greatest common divisor
 FR: Programme c++ de calculer le plus grand commun diviseur
------------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

int main()
{   int aux, max_divisor, value1, value2; 
    printf("\nPT: introduz um numero inteiro\n");
    printf("EN: put a integer number\n");
    printf("FR: tappez un numero entiere\n");
    scanf("%d",&value1);
    printf("\nPT: introduz outro numero\n");
    printf("EN put another integer number\n");
    printf("FR: tappez un autre numero\n");
    scanf("%d",&value2);
    if (value1<value2) aux=value1; else aux=value2;
    for(int it=1; it<= aux ;it++)
    { if ((value1%it ==0)||(value2%it==0))
        printf("\n%d mod %d =%d    %d mod %d =%d",value1, it, value1%it ,value2, it, value2%it);
        if ((value1%it ==0) &&( value2%it==0)) max_divisor=it;
    }
   
    printf("\n\nPT: O maximo divisor comum é %d\n",max_divisor);
    printf("EN: maximum common divisor %d\n",max_divisor);
    printf("FR: diviseur commun maximale %d\n",max_divisor);

    return 0;
}

---------------------------------------------------------------------------------------------------------------------------------------------------------------------
the output of the program when i put the integers 100 and 80

100 mod 1 =0    80 mod 1 =0
100 mod 2 =0    80 mod 2 =0
100 mod 4 =0    80 mod 4 =0
100 mod 5 =0    80 mod 5 =0
100 mod 8 =4    80 mod 8 =0
100 mod 10 =0    80 mod 10 =0
100 mod 16 =4    80 mod 16 =0
100 mod 20 =0    80 mod 20 =0
100 mod 25 =0    80 mod 25 =5
100 mod 40 =20    80 mod 40 =0
100 mod 50 =0    80 mod 50 =30
100 mod 80 =20    80 mod 80 =0

PT: O maximo divisor comum é 20
EN: maximum common divisor 20
FR: diviseur commun maximale 20
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

another output
PT: introduz um numero inteiro
EN: put a integer number
FR: tappez un numero entiere
3

PT: introduz outro numero
EN put another integer number
FR: tappez un autre numero
5

3 mod 1 =0    5 mod 1 =0
3 mod 3 =0    5 mod 3 =2

PT: O maximo divisor comum é 1
EN: maximum common divisor 1
FR: diviseur commun maximale 1

sexta-feira, 6 de novembro de 2015

Area do circulo - Perimetro da circunferencia

 Pi       π = 3.14159  
Calculate area (A) and perimeter (P)
Calcular área (A) e perimetro (P)
Calculer la superficie (A) et le périmètre (P)

 R=3 m

P=2 * pi * R
P=2 * pi * 3
P=6 pi 
P=18,84954 metro

A= pi * R²
A= pi * 3 * 3
A= 9 pi
A= 28,27431 metro²

terça-feira, 3 de novembro de 2015

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  ;

segunda-feira, 2 de novembro de 2015

Com estes diodos consegue-se ter uma saída a nivel logico alto desde que uma das entradas esteja a nivel lógico alto. Para termos a saída a nível lógico baixo temos de ter as duas entradas a nível lógico baixo. Este circuito implementa a função lógica OU do ingês OR. A saída é "1" se A OU B a "1".

With these diodes can get an output logical high level as long as one of the inputs is the logic high level. To get the output to logic low level we must have both inputs to logic low. This circuit implements the logic OR function . The output is "1" if A OR B "1".

Avec ces diodes peuvent obtenir une sortie haut niveau logique aussi longtemps que l'une des entrées est le haut niveau de la logique. Pour obtenir la sortie à niveau logique bas, nous devons avoir les deux entrées à logique bas. Ce circuit met en oeuvre la fonction logique OU de l'anglais OR. La sortie est "1" si A ou B "1".


________________________________________________________________________________



Com estes diodos consegue-se ter uma saída a nivel logico alto só quando ambas as entradas estão a nivel lógico alto. Temos a saída a nível lógico baixo desde que uma das entradas esteja a nível lógico baixo. Este circuito implementa a função lógica E, do ingês AND. A saída é "1" se A E B a "1".

With these diodes is achieved by having a logical high level output only when both inputs are logic high level. We have the output to logic low since one of the inputs is a logic low. This circuit implements the logic function AND. The output is "1" if A AND B is "1".

Avec ces diodes est réalisé en ayant une sortie de haut niveau logique que lorsque les deux entrées sont la logique de haut niveau. Nous avons la sortie à l'état logique bas depuis l'une des entrées est un bas logique. Ce circuit met en oeuvre la fonction logique ET, le AND anglais. La sortie est à "1" si A et B à "1".

sábado, 31 de outubro de 2015



PT: Resolução de sistemas de 2 equações a 2 incógnitas pelo método dos determinantes. Regra de Cramer

EN: Resolution of 2 equations to 2 unknowns by the method of determining systems. Rule Cramer

FR:Résolution des équations 2 à 2 inconnues par la méthode de détermination systèmes. Règle Cramer


|-ax+k=by     
|cx-dy+w=0  

PT: Quando temos um sistema temos de o arrumar: x , y e termo independente

EN: When we have a system we have to fix: x, y independent term 

FR:Lorsque nous avons un système que nous avons à fixer: x, y terme indépendant

|-ax-by=-k       |-a   -b|
|cx-dy=-w       |c    -d|

  
     |-k   -b|
     |-w  -d|         (-k * -d ) - (-w * -b)
x= ------------  = ---------------------------------
      |-a   -b|        (-a * -d) - (c * -b)
      |c    -d|


     |-a   -k|
     |c    -w|         (-a * -w ) - (c * -k)
y= ------------  = ---------------------------------
      |-a   -b|        (-a * -d) - (c * -b)
      |c    -d|


quarta-feira, 28 de outubro de 2015

PT: Resolução de sistemas de 2 equações a 2 incógnitas pelo método da adição
EN:Resolution of 2 equations with 2 unknowns by the addition method
FR:Résolution des équations 2 à 2 inconnues par la méthode des ajouts 


| x+y=12             há que passar este 2x para o outro lado
| y=2x <-- pass the 2x to the left side  
                            passer le 2x pour le autre cote


|   x+y=12             multiplicar aqui por -1
|-2x+y=0 <-- multiplication here by -1
                             faire la multiplication pour le -1

| x+y=12               somar as duas equações
|2x-y=0                  do the adition of this two equations      

----------------              faire la aditions de ce 2 equations
  3x  =12
 x=12/3 => x=4
                                
                                 multiplicar aqui por 2
|   x+y=12 <--  multiplication here by 2
|-2x+y=0                  multiplier ici pour 2


| 2x+2y=24           add the 2 equations  somar as 2 equações
|-2x+ y=0              ajouter les deux équations
-----------------
      3y=24  <=> y=24/3 => y=8


sábado, 24 de outubro de 2015


programa em pascal

program exemplo;
uses crt;
var quantidade:real;
   preco:real;
begin
  clrscr;
  writeln;
  writeln('Programa para calcular o custo total de uma certa quantidade');
  writeln('de mercadoria a um determinado preço');
  writeln;
  repeat
     writeln;
     writeln('quantas unidades ? "introduza 0 para saír"'); 
     readln(quantidade);
     if(quantidade>0) then
     begin
       writeln('qual o preço de cada unidade?');
       readln(preco);
       if(preco>0) then writeln(' tem a pagar ', quantidade*preco);
     end;
  until quantidade=0;
end.

------------------------ output do programa-----------------------------------------------