Mostrando entradas con la etiqueta numeros. Mostrar todas las entradas
Mostrando entradas con la etiqueta numeros. Mostrar todas las entradas

viernes, 18 de enero de 2019

programacion en prolog suma de lista de numeros con recursividad


_____________________________________________

(defun lista (a b c d e)
(setq li (list a b c d e))
(setq suma 0)
(setq i 0)
(while (< i 5)
(setq  val (nth i li)
)

(setq i (+ i 1))
(setq suma(+ suma val))
)
____________________________________________


miércoles, 18 de mayo de 2016

numeros primos C++

numeros primos C++


#include<iostream>
using namespace std;

int main(){

unsigned int numero, n, p, num_columnas;
cout <<"Introduzca hasta que numero quiere llegar ";
cin >> numero;
cout <<'n' << endl;
num_columnas = 0 ;
n=2;
while (n <= numero){
for ( p = 2; n % p!= 0; p++);
if ( p == n){
cout << n <<", ";
if(++num_columnas % 10 == 0)// controla el numero de elementos en una fila
cout <<"n" << endl;
}
n++;
}

cout <<"Fin de Programa. n" << endl;
system ("pause";
return 0;
}

Numeros primos C++

Numeros primos C++

#include <iostream.h>
bool primo(int);
int main(){
int x;
cin>>x;
if(primo(x))
cout<<"n Es primo";
else
cout<<"n No es primo";
return 0;

}

bool primo(int x){
if(x==1||x==2)
return true;
else{
int i;
for(i=2;i<x;i++){
if(x%i==0)
return false;
}
}
return true;
}

lunes, 16 de mayo de 2016

determinar el menor de 5 numeros sentencia if



determinar el menor de 5 numeros



import java.io.*;



class prop4 {

public static void main(String[]args)throws IOException

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

<!--more-->

System.out.print("ingresar numero a:");

int a=Integer.parseInt(in.readLine());

System.out.print("ingrese numero b:");

int b=Integer.parseInt(in.readLine());

System.out.print("ingresar numero c:");

int c=Integer.parseInt(in.readLine());

System.out.print("ingrese numero d:");

int d=Integer.parseInt(in.readLine());

System.out.print("ingrese numero e:");

int e=Integer.parseInt(in.readLine());

if ((a<b && a < c && a < d&& a < e)
{

System.out.println(" menor es : "+a);

}

else if ((b<a && b < c && b < d && b < e)
{

System.out.println(" menor es : "+b);

}

else if ((c<a && c < b && c < d && b < e))

{

System.out.println(" menor es : "+c);

}

else if ((d<a && d < b && d<c && d < e)
{

System.out.println(" menor es : "+d);

}

else

{

System.out.println(" menor es : "+e);

}

}

}

producto y suma de dos numeros



producto y suma de dos numeros

import java.io.*;




class propuesto3producysuma{

public static void main(String[]args) throws IOException

{

BufferedReader in=new BufferedReader (new InputStreamReader(System.in));

<!--more-->

System.out.print("ingrese el primer numero positivo: ");

int a=Integer.parseInt(in.readLine());

System.out.print("ingrese el segundo número positivo:");

int b=Integer.parseInt(in.readLine());


int c;


if ((a>0) &&(b&gt;0))

{ c=a*b;


System.out.println("el producto de dichos numeros es:"+c);

}

else {

c=a+b;

System.out.println("la suma de dichos numeros es:"+c);

}



}

}

SI LAS VOCALES se representan con numeros del 1 al 5 en sentencias Switch



SI LAS VOCALES se representan con numeros del 1 al 5 en sentencias Switch

import java.io.*;



class switchp_1{

public static void main(String args[])throws IOException{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

int i;

System.out.println("Pograma que muestra una vocal al ingresar su orden");
<!--more-->
System.out.println("Ingrese orden");

i=Integer.parseInt(in.readLine());

switch(i){

case 1:System.out.println("a");

break;

case 2:System.out.println("e");

break;

case 3:System.out.println("i");

break;

case 4:System.out.println("o");

break;

case 5:System.out.println("u");

break;

}


}


} 

ENTRADAS POPULARES