Progra
Progra
ngSy
stem;
Cl
assPr
ogr
am
St
ati
cvoi
dMai
n()
Consol
e.Wr
it
eLi
ne(
“El
i
geunaf
igur
apar
acal
cul
arár
eayper
ímet
ro:
”)
;
Consol
e.Wr
it
eLi
ne(
“1.Cí
rcul
o”)
;
Consol
e.Wr
it
eLi
ne(
“2.Cuadr
ado”
);
Consol
e.Wr
it
eLi
ne(
“3.Tr
iángul
o”)
;
I
ntopci
on=i
nt.
Par
se(
Consol
e.ReadLi
ne(
));
Doubl
ear
ea,
per
imet
ro;
Swi
tch(
opci
on)
Case1:
Consol
e.Wr
it
e(“
Int
roduceel
radi
odel
cír
cul
o:“
);
Doubl
eradi
o=doubl
e.Par
se(
Consol
e.ReadLi
ne(
));
Cal
cul
arCi
rcul
o(r
adi
o,outar
ea,
outper
imet
ro)
;
Br
eak;
Case2:
Consol
e.Wr
it
e(“
Int
roduceel
ladodel
cuadr
ado:
“);
Doubl
elado=doubl
e.Par
se(
Consol
e.ReadLi
ne(
));
Cal
cul
arCuadr
ado(
lado,
outar
ea,
outper
imet
ro)
;
Br
eak;
Case3:
Consol
e.Wr
it
e(“
Int
roducel
abasedel
tri
ángul
o:“
);
Doubl
ebaseT=doubl
e.Par
se(
Consol
e.ReadLi
ne(
));
Consol
e.Wr
it
e(“
Int
roducel
aal
tur
adel
tri
ángul
o:“
);
Doubl
eal
tur
a=doubl
e.Par
se(
Consol
e.ReadLi
ne(
));
Consol
e.Wr
it
e(“
Int
roducel
osot
rosdosl
adosdel
tri
ángul
o(separ
ados
porespaci
o):
“);
St
ri
ng[
]lados=Consol
e.ReadLi
ne(
).
Spl
i
t()
;
Doubl
elado1=doubl
e.Par
se(
lados[
0])
;
Doubl
elado2=doubl
e.Par
se(
lados[
1])
;
Cal
cul
arTr
iangul
o(baseT,
alt
ura,
lado1,
lado2,
outar
ea,
outper
imet
ro)
;
Br
eak;
Def
aul
t:
Consol
e.Wr
it
eLi
ne(
“Opci
ónnov
áli
da.
”)
;
Ret
urn;
Consol
e.Wr
it
eLi
ne(
“Ár
ea:
“+ar
ea)
;
Consol
e.Wr
it
eLi
ne(
“Per
ímet
ro:
“+per
imet
ro)
;
St
ati
cvoi
dCal
cul
arCi
rcul
o(doubl
eradi
o,outdoubl
ear
ea,
outdoubl
e
peri
metr
o)
Ar
ea=Mat
h.PI*r
adi
o*r
adi
o;
Per
imet
ro=2*Mat
h.PI*r
adi
o;
St
ati
cvoi
dCal
cul
arCuadr
ado(
doubl
elado,
outdoubl
ear
ea,
outdoubl
e
peri
metr
o)
Ar
ea=l
ado*l
ado;
Per
imet
ro=4*l
ado;
St
ati
cvoidCal
cul
arTr
iangul
o(doubl
ebaseT,doubl
eal
tur
a,doubl
elado1,
doubl
elado2,
outdoubl
earea,outdoubl
eperi
metro)
Ar
ea=(
baseT*al
tur
a)/2;
Per
imet
ro=baseT+l
ado1+l
ado2;
}
Usi
ngSy
stem;
Cl
assPr
ogr
am
St
ati
cvoi
dMai
n()
Consol
e.Wr
it
eLi
ne(
“Conv
ersordeUni
dades”
);
Consol
e.Wr
it
eLi
ne(
“1.Met
rosaPi
es”
);
Consol
e.Wr
it
eLi
ne(
“2.Ki
l
ogr
amosaLi
bras”
);
Consol
e.Wr
it
eLi
ne(
“3.Li
tr
osaGal
ones”
);
Consol
e.Wr
it
eLi
ne(
“El
i
geunaopci
ón(
1-3)
:”
);
St
ri
ngopci
on=Consol
e.ReadLi
ne(
);
Doubl
eval
or,
resul
tado;
Swi
tch(
opci
on)
Case“
1”:
Consol
e.Wr
it
e(“
Ingr
esal
osmet
ros:
“);
Val
or=Conv
ert
.ToDoubl
e(Consol
e.ReadLi
ne(
));
Resul
tado=Met
rosAPi
es(
val
or)
;
Consol
e.Wr
it
eLi
ne(
val
or+“met
rosson“+r
esul
tado+“pi
es.
”)
;
Br
eak;
Case“
2”:
Consol
e.Wr
it
e(“
Ingr
esal
oski
l
ogr
amos:
“);
Val
or=Conv
ert
.ToDoubl
e(Consol
e.ReadLi
ne(
));
Resul
tado=Ki
l
ogr
amosALi
bras(
val
or)
;
Consol
e.Wr
it
eLi
ne(
val
or+“ki
l
ogr
amosson“+r
esul
tado+“l
i
bras.
”)
;
Br
eak;
Case“
3”:
Consol
e.Wr
it
e(“
Ingr
esal
osl
i
tros:
“);
Val
or=Conv
ert
.ToDoubl
e(Consol
e.ReadLi
ne(
));
Resul
tado=Li
tr
osAGal
ones(
val
or)
;
Consol
e.Wr
it
eLi
ne(
val
or+“l
i
trosson“+r
esul
tado+“gal
ones.
”)
;
Br
eak
Def
aul
t:
Consol
e.Wr
it
eLi
ne(
“Opci
ónnov
áli
da.
”)
;
Br
eak;
St
ati
cdoubl
eMet
rosAPi
es(
doubl
emet
ros)
Ret
urnmet
ros*3.
28084;
St
ati
cdoubl
eKi
l
ogr
amosALi
bras(
doubl
eki
l
ogr
amos)
Ret
urnki
l
ogr
amos*2.
20462;
St
ati
cdoubl
eLi
tr
osAGal
ones(
doubl
eli
tr
os)
Ret
urnl
i
tros*0.
264172;
}
Usi
ngSy
stem;
Cl
assPr
ogr
am
St
ati
cvoi
dMai
n()
Consol
e.Wr
it
e(“
Ingr
esel
acant
idaddenúmer
os:
“);
I
ntcant
idadNumer
os=i
nt.
Par
se(
Consol
e.ReadLi
ne(
));
Doubl
esuma=0;
Doubl
esumaCuadr
ados=0;
Doubl
emedi
a,medi
ana,
var
ianza,
desv
iaci
onEst
andar
;
I
ntnumer
o,numer
oMedi
ana1=0,
numer
oMedi
ana2=0
For(
inti
=1;
i<=cant
idadNumer
os;
i++)
Consol
e.Wr
it
e(“
Ingr
eseel
númer
o“+i
+“:
“);
Numer
o=i
nt.
Par
se(
Consol
e.ReadLi
ne(
));
Suma+=numer
o;
sumaCuadr
ados+=numer
o*numer
o;
/
/Cal
cul
arl
amedi
ana“
env
ivo”si
nusarunar
ray
I
f(i
==(
cant
idadNumer
os+1)/2)
numer
oMedi
ana1=numer
o;
}
I
f(cant
idadNumer
os%2==0&&i
==(
cant
idadNumer
os/2)+1)
numer
oMedi
ana2=numer
o;
Medi
a=suma/cant
idadNumer
os;
Consol
e.Wr
it
eLi
ne(
“Medi
a:“+medi
a);
Medi
ana=(cant
idadNumer
os%2==0)¿(numer
oMedi
ana1+
numer
oMedi
ana2)/2.0:numer
oMedi
ana1;
Consol
e.Wr
it
eLi
ne(
“Medi
ana:
“+medi
ana)
;
Var
ianza=(
sumaCuadr
ados/cant
idadNumer
os)–(
medi
a*medi
a);
desv
iaci
onEst
andar=Apr
oxi
mar
Rai
zCuadr
ada(
var
ianza)
;
Consol
e.Wr
it
eLi
ne(
“Desv
iaci
ónEst
ándar
:“+desv
iaci
onEst
andar
);
St
ati
cdoubl
eApr
oxi
mar
Rai
zCuadr
ada(
doubl
enumer
o)
Doubl
eest
imaci
on=numer
o/2.
0;
For(
inti
=0;
i<10;
i++)/
/It
eraci
ónbási
ca,
ajust
asegúnl
apr
eci
sión
deseada
Est
imaci
on=(
est
imaci
on+numer
o/est
imaci
on)/2.
0;
Ret
urnest
imaci
on;
}
Si
ngSy
stem:
Cl
assPr
ogr
am
St
ati
cvoi
dMai
n()
Consol
e.Wr
it
e(“
Ingr
esel
acant
idaddeel
ement
osdel
osv
ect
ores:
“);
I
ntcant
idadEl
ement
os=i
nt.
Par
se(
Consol
e.ReadLi
ne(
));
St
ri
ng[
]vect
orA=newst
ri
ng[
cant
idadEl
ement
os]
;
Consol
e.Wr
it
eLi
ne(
“I
ngr
esel
osel
ement
osdel
vect
orA:
”)
;
For(
inti
=0;
i<cant
idadEl
ement
os;
i++)
Consol
e.Wr
it
e(“
Element
o“+(
i+1)+“deA:
“);
v
ect
orA[
i]=Consol
e.ReadLi
ne(
);
St
ri
ng[
]vect
orB=newst
ri
ng[
cant
idadEl
ement
os]
;
Consol
e.Wr
it
eLi
ne(
“I
ngr
esel
osel
ement
osdel
vect
orB:
”)
;
For(
inti
=0;
i<cant
idadEl
ement
os;
i++)
Consol
e.Wr
it
e(“
Element
o“+(
i+1)+“deB:
“);
v
ect
orB[
i]=Consol
e.ReadLi
ne(
);
St
ri
ng[
]vect
orResul
tado=newst
ri
ng[
cant
idadEl
ement
os]
;
For(
inti
=0;
i<cant
idadEl
ement
os;
i++)
{
vectorResul
tado[
i]=v
ect
orA[
i]+v
ect
orB[
i]
;//Concat
enarel
ement
os
cor
respondientes
Consol
e.Wr
it
eLi
ne(
“Vect
orr
esul
tant
e:”
);
For(
inti
=0;
i<v
ect
orResul
tado.
Lengt
h;i
++)
Consol
e.Wr
it
eLi
ne(
“El
ement
o“+(
i+1)+“
:“+v
ect
orResul
tado[
i]
);
Si
ngSy
stem;
Cl
assPr
ogr
am
St
ati
cvoi
dMai
n()
{
I
ntn=i
nt.
Par
se(
Consol
e.ReadLi
ne(
));
I
nt[
]vec=newi
nt[
n];
For(
inti
=0;
i<n;
i++)v
ec[
i]=i
nt.
Par
se(
Consol
e.ReadLi
ne(
));
I
ntnum =i
nt.
Par
se(
Consol
e.ReadLi
ne(
));
I
ntcnt=0;
For(
inti
=0;
i<n;
i++)
I
f(v
ec[
i]¡
=num)cnt
++;
I
f(cnt==n)
Consol
e.Wr
it
eLi
ne(
“Númer
onoencont
rado”
);
El
se
I
nt[
]res=newi
nt[
cnt
];
I
ntj
=0;
For(
inti
=0;
i<n;
i++)
I
f(v
ec[
i]¡
=num)
Res[
j]=v
ec[
i]
;
J++;
For(
inti
=0;
i<cnt
;i++)
{
Consol
e.Wr
it
e(r
es[
i]+““
);
Si
ngSy
stem;
Cl
assPr
ogr
am
St
ati
cvoi
dMai
n()
Consol
e.Wr
it
e(“
Ingr
esel
acant
idaddeel
ement
osdel
vect
or:
“);
I
ntn=i
nt.
Par
se(
Consol
e.ReadLi
ne(
));
I
nt[
]vect
or=newi
nt[
n];
Consol
e.Wr
it
eLi
ne(
“I
ngr
esel
osel
ement
osdel
vect
or:
”)
;
For(
inti
=0;
i<n;
i++)
Vect
or[
i]=i
nt.
Par
se(
Consol
e.ReadLi
ne(
));
I
ntsumaPar
es=0;
Consol
e.Wr
it
e(“
Númer
ospar
es:
“);
For(
inti
=0;
i<n;
i++)
I
f(v
ect
or[
i]%2==0)
Consol
e.Wr
it
e(v
ect
or[
i]+““
);
sumaPar
es+=v
ect
or[
i]
;
Consol
e.Wr
it
eLi
ne(
);
Consol
e.Wr
it
eLi
ne(
“Sumadel
osnúmer
ospar
es:
“+sumaPar
es)
;
Usi
ngSy
stem;
Cl
assPr
ogr
am
St
ati
cvoi
dMai
n()
{
I
nt[
]vect
or=Ll
enar
Vect
or(
);
Consol
e.Wr
it
eLi
ne(
“Vect
oror
igi
nal
:
”);
Most
rar
Vect
or(
vect
or)
;
Consol
e.Wr
it
eLi
ne(
“Númer
ospr
imos:
”)
;
Most
rar
Vect
or(
Fil
tr
arPr
imos(
vect
or)
);
St
ati
cint
[]Ll
enar
Vect
or(
)
I
nt[
]temp=newi
nt[
100]
;
I
ntcount=0;
Whi
l
e(t
rue)
I
ntnum =i
nt.
Par
se(
Consol
e.ReadLi
ne(
));
I
f(num ==0)br
eak;
Temp[
count
++]=num;
Ar
ray
.Resi
ze(
reft
emp,
count
);
Ret
urnt
emp;
St
ati
cbool
EsPr
imo(
intnum)
I
f(num <2)r
etur
nfal
se;
For(
inti
=2;
i*i
<=num;
i++)
I
f(num %i
==0)r
etur
nfal
se;
Ret
urnt
rue;
}
St
ati
cint
[]Fi
l
trar
Pri
mos(
int
[]v
ect
or)
I
ntcount=0;
For
each(
intnum i
nvect
or)
I
f(EsPr
imo(
num)
)count
++;
I
nt[
]pr
imos=newi
nt[
count
];
I
nti
=0;
For
each(
intnum i
nvect
or)
I
f(EsPr
imo(
num)
)
Pr
imos[
i]=num;
I
++;
Ret
urnpr
imos;
St
ati
cvoi
dMost
rar
Vect
or(
int
[]v
ect
or)
For
each(
intnum i
nvect
or)
Consol
e.Wr
it
e(num +““
);
Consol
e.Wr
it
eLi
ne(
);