Practica 710

download Practica 710

of 8

Transcript of Practica 710

  • 7/26/2019 Practica 710

    1/8

    1

    Table of Contents

    ...................................................... ....................................................... ........................... 1

    ESTE ES UN ARDUO TRABAJO REALIZADO POR ...... ..... ...... ...... ..... ...... ..... ...... ...... ..... ..... 1

    ejercicio710 ..................................................... ....................................................... ............ 1EJERCICIO 3 ................................................. ........................................................ ............ 2

    introduccion de valores ...... ..... ...... ...... ..... ...... ..... ...... ...... ..... ...... ..... ...... ...... ..... ...... ..... ..... .... 2

    OTRO ALGORITMO ................................ ........................................................ .................. 2

    OTRO ALGORITMO ................................ ........................................................ .................. 2

    pida una letra i diga si es vocal o no es vocal ......... ..... ...... ..... ...... ...... ..... ...... ..... ...... ...... ..... .... 3

    OTRO ALGORITMO ................................ ........................................................ .................. 3

    OTRO ALGORITMO ................................ ........................................................ .................. 4

    OTRO ALGORITMO ................................ ........................................................ .................. 4

    OTRO AGORITMO ................................................ ........................................................ .... 5

    OTRO ALGOROITMO .................................................... .................................................... 5

    OTRO ALGORITMO ................................ ........................................................ .................. 6

    introduccion de valores ...... ..... ...... ...... ..... ...... ..... ...... ...... ..... ...... ..... ...... ...... ..... ...... ..... ..... .... 6

    OTRO ALGORITMO ................................ ........................................................ .................. 6

    OTRO ALGORITMO ................................ ........................................................ .................. 7

    ALGORITMO ................................................ ....................................................... ............. 8

    %

    Error: File: C:\Users\famador\Desktop\practica6 de mathlab\PRACTICA7

    Illegal use of reserved keyword "end".

    ESTE ES UN ARDUO TRABAJO REALIZADO

    PORJESUS ASENCIO RODRIGUEZ HENRY GARCIA FLORIAN

    ejercicio710% introducir un numero porel teclado y hacer preguntas

    disp('introduzca un numerocualquiera');

    num=input('');

    fprintf('\n')

    ifnum>0

    fprintf('\n')

    pot=num^2;

    rai=sqrt(num);

    disp(['su potencia es igual a ',num2str(pot)]);

    fprintf('\n')

    fprintf('\n')

    disp(['su raiz cuadrada es igual a ',num2str(rai)]);

    else

    fprintf('\n')

    fprintf('\n')

    disp('error, introduce un numero mayor que cero');

  • 7/26/2019 Practica 710

    2/8

    2

    end

    end

    EJERCICIO 3

    % Realizar un algoritmo que dado un nmero entero, visualice% en pantalla si es par o impar. En el caso de ser 0, debe visualizar

    % el nmero no es par ni impar

    introduccion de valores% DADO UN NUMERO DECIR SI ES PARA O IMPAR

    % SI EL NUMERO ES CERO DECIR NO ES NI PAR NI IMPAR

    disp('INTRODUCIR UN NUMERO CUALQUIERA');

    num=input(' ');

    % REALIZA COMPARACION USANDO EL SI

    disp(' ');

    ifmod(num,2)==0

    disp(['EL NUMERO ',num2str(num),' ES PAR']);

    else

    fprintf('\n')

    disp(['EL NUMERO ',num2str(num),' ES IMPAR']);

    end

    OTRO ALGORITMO % este algoritmo pide tres numero y lo muestra de nemor a mayor

    disp('INTRODUCIR TRES NUMERO Y PRESENTARLO DE MENOR A MAYOR');

    disp(' ');

    disp(' nunero A ');

    a=input('');

    disp(' nunero B ');

    b=input('');

    disp(' nunero C ');

    c=input('');

    ifa

  • 7/26/2019 Practica 710

    3/8

    3

    disp('PIDA UN NUMERO Y DIGA SI ES POSITIVO O NEGATIVO');

    a=input('');

    ifa

  • 7/26/2019 Practica 710

    4/8

    4

    mayorr=n(x);

    menorr=n(x);

    end

    ifn(x)>mayorr

    mayorr=n(x);

    end

    ifn(x)mayorr

    mayorr=n(x);

    end

    ifn(x)

  • 7/26/2019 Practica 710

    5/8

    5

    suma=num1+num2;

    resta=num1-num2;

    multiplicacion=num1*num2;

    division=num1/num2;

    fprintf('\n')

    fprintf('\n')

    disp([' la suma de los numeros es igual a ',num2str(suma)]);fprintf('\n')

    fprintf('\n')

    disp([' la resta de los numeros es igual a ',num2str(resta)]);

    fprintf('\n')

    disp([' la multiplicacion de los numeros es igual a ',num2str(multip

    fprintf('\n')

    fprintf('\n')

    disp([' la division de los numeros es igual a ',num2str(division)]);

    OTRO AGORITMO % Algoritmo que lea tres nmeros distintos y nos diga

    % cual de ellos es el mayor (recuerda usar la estructura condicional

    % Si y los operadores lgicos).

    fprintf(' ALGORITMO')

    disp(' INTRODUCCION DE VARIABLES');

    fprintf('\n')

    disp(' VALOR DEL PRIMER NUMERO');

    fprintf('\n')

    num1=input(' VALOR DEL PRIMER NUMERO');

    fprintf('\n')

    disp(' VALOR DEL SEGUNDO NUMERO');

    fprintf('\n')

    num2=input(' segundo NUMERO ');fprintf('\n');

    disp(' VALOR DEL TERCER NUMERO');

    fprintf('\n')

    num3=input(' TERCER NUMERO ');

    % USAMOS CONDICIONAL SI Y OPERADORES LOGICO

    ifnum1>num2, num1>num3

    disp(['EL NUMERO MAYOR ES EL ',num2str(num1)]);

    else

    ifnum2>num3

    disp(['EL NUMERO MAYOR ES EL ',num2str(num2)]);

    else

    disp(['EL NUMERO MAYOR ES EL ',num2str(num3)]);

    end end

    OTRO ALGOROITMO % Este codigo ha sido generado por el modulo psexport 20160408-w32 de PS

    % Es posible que el codigo generado no sea completamente correcto. Si encuen

    % errores por favor reportelos en el foro (http://pseint.sourceforge.net).

  • 7/26/2019 Practica 710

    6/8

    6

    % LEER TRES NUMEROS SI EL PRIMERO ES NEGATIVO

    % MULTIPLICAR LOS OTROS DOS, SI ES POSITIVO

    % SUMAR LOS OTROS DOS"*/

    disp('INRODUCIR LOS VALORES DE TRES NUMERO CUALQUIERA ENTEROS');

    fprintf('\n')disp('VALOR DEL PRIMER NUMERO');

    num1=input('');

    fprintf('\n')

    fprintf('\n')

    disp('VALOR DEL SEGUNDO NUMERO');

    num2=input('');

    fprintf('\n')

    disp('VALOR DEL TERCER NUMERO');

    num3=input('');

    % USO DE CONDICIONANTE

    ifnum1

  • 7/26/2019 Practica 710

    7/8

    7

    % DADO UN NUMERO DECIR SI ES PARA O IMPAR

    % SI EL NUMERO ES CERO DECIR NO ES NI PAR NI IMPAR

    disp('INTRODUCIR UN NUMERO CUALQUIERA');

    num=input('');

    % REALIZA COMPARACION USANDO EL SI

    fprintf('\n');whilenum==0

    disp('ENTRE EL NUMERO NUEVAMENTE');

    fprintf('\n')

    num=input('');

    end

    ifmod(num,2)==0

    disp(['EL NUMERO ',num2str(num),' ES PAR']);

    else

    disp(' ');

    fprintf('\n')

    disp(['EL NUMERO ',num2str(num),' ES IMPAR']);

    end

    %

    OTRO ALGORITMO

    disp(' LOS NUMEROS DEL 1 AL 9 Y SUS RESPECTIVOS CUADRADOS');

    fprintf('\n')

    fprintf('\n')

    fornum=1:9

    res=num^2;

    disp([' PARA EL NUMERO ',num2str(num),' SU CUADRADO ES ',num2str(res

    end

    % Se pide representar el algoritmo que nos calcule la

    % suma de los N primeros nmeros pares. Es decir, si insertamos un 5,

    % nos haga la suma de 6+8+10+12+14

    n=input('introduccir el limites para sumar los pares comprendido');

    contador=0;

    limite=n;

    suma=0;

    ifn==5

    m=6+8+10+12+14;

    disp([('las suma de 6+8+10+12+14 :'),num2str(m)]);

    n=0;

    end

    while(contador

  • 7/26/2019 Practica 710

    8/8

    8

    ALGORITMO

    % Este codigo ha sido generado por el modulo psexport 20160408-w32 de PS

    % Es posible que el codigo generado no sea completamente correcto. Si encuen

    % errores por favor reportelos en el foro (http://pseint.sourceforge.net).

    functionpractica73()

    disp('Introduce el primer numero');

    numero1=input('');

    disp('Introduce el segundo numero');

    numero2=input('');

    % comparamos los dos numeros,

    % si el primero es mayor o igual que el segundo entra

    if(numero1>=numero2)

    % Si el numero1 y numero2 son iguales entra y escribe que son iguales

    % Sino lo son escribe que el numero1 es el mayor

    if(numero1==numero2)

    disp(['los numeros ',num2str(numero1),' ',num2str(numero2),' son iguales' else

    disp([num2str(numero1),' es el mayor de los dos']);

    end

    % Si el primer Si es falso, escribe que el numero2 es mayor

    else

    disp([num2str(numero2),' es el mayor de los dos']);

    end

    Published with MATLAB R2014a