Professional Documents
Culture Documents
PRÁCTICA # 15
DIAGRAMA DE FLUJO
UNIVERSIDAD MAYOR DE SAN ANDRES FECHA: 15/04/2018
CODIGO JAVA
import java.util.Scanner;
public class ejer1
{
static int fibo(int w){
int p=0,a=0,b=1,c=1,i;
for(i=1; i<=w; i++){
p=a; a=b; b=c; c=a+b;
}
return p;
}
static int clasic(int w){
int i,a=1,b=0,c=1;
for(i=1; i<=w; i++){
if(b==c){
c++;
b=1;
a++;
}
else{
b++;
}
}
return a;
}
static int facto(int w){
int i,f=1;
for(i=1; i<=w; i++){
f=f*i;
}
return f;
UNIVERSIDAD MAYOR DE SAN ANDRES FECHA: 15/04/2018
}
public static void main(String[] args)
{ Scanner sc=new Scanner(System.in);
int n,a,a1,b,b1;
double s=0;
System.out.print("Intro n=");
n=sc.nextInt();
for(int i=1; i<=n; i++){
a=fibo(i);
b=clasic(i);
a1=facto(a);
b1=facto(b);
s=s+(double)a1/b1;
System.out.print("+"+a+"!/"+b+"! ");
}
System.out.print("="+s);
}
}
CAPTURA DE PANTALLA
Hecho por Mamani Pajarito Jhonathan Kevin el 15 de abril del 2018 en la UMSA
UNIVERSIDAD MAYOR DE SAN ANDRES FECHA: 15/04/2018
2° Dado un lote de n números rotar los extremos a la derecha. Hecho por Mamani Pajarito
Jhonathan Kevin el 15 de abril del 2018 en la UMSA.
DIAGRAMA DE FLUJO
UNIVERSIDAD MAYOR DE SAN ANDRES FECHA: 15/04/2018
CODIGO JAVA
import java.util.Scanner;
public class ejer2
{
static int p1,p2,p3;
static void extre(int w){
int a,b,d=0,cd=0,n=w,c=0;
while(w!=0){
w=w/10;
cd++;
}
w=n;
b=w%10;
a=w/(int)Math.pow(10, cd-1);
cd=0;
while(w!=0){
c=w%10;
w=w/10;
cd++;
if(c==a){
d=cd;
}
}
p1=a; p2=b; p3=d;
}
n1=n1/10;
nn=a*(int)Math.pow(10, cd-1)+n1*10+b;
System.out.println("nuevo número:"+nn);
}
}
}
}
}
CAPTURA DE PANTALLA
Hecho por Mamani Pajarito Jhonathan Kevin el 15 de abril del 2018 en la UMSA.