Documentos de Académico
Documentos de Profesional
Documentos de Cultura
NOMBRE: ………………………………….
CODIGO: ………………………………….
using System;
class Program {
static void Main(string[] args) {
Console.Write("Ingrese un numero > ");
int d = int.Parse(Console.ReadLine());
int res;
int div=d;
Console.Write(d+" (base 10) <--> ");
while(div>0){
res= div%8;
div=div/8;
Console.Write(res);
}
Console.Write(" (base 8)");
}
}
2. Diseñar un algoritmo que permita ingresar n caracteres desde el
teclado y contar cuantos de esos caracteres son letras mayúsculas,
letras minúsculas, dígitos y caracteres especiales (auto o mecánica
B)
@Qtiu3/70)
Mayúsculas= 1
Minúsculas= 3
Dígitos= 3
Caracteres especiales= 3
using System;
class Program {
static void Main(string[] args) {
Console.Write("Ingrese un numero de caracteres > ");
int d = int.Parse(Console.ReadLine());
Console.Write("Ingrese los caracteres > ");
string entrada = Console.ReadLine();
int may=0;
int min=0;
int num=0;
int car=0;
for(int i=0;i<d;i++){
char ltr= entrada[i];
bool sim=true;
if(Char.IsUpper(ltr)){
may++;
sim=false;
}
if(Char.IsLower(ltr)){
min++;
sim=false;
}
if(Char.IsDigit(ltr)){
num++;
sim=false;
}
if(sim){
car++;
}
}
Console.WriteLine("Mayusculas: "+ may + "\nMinusculas: "+min+"
\nNumeros: "+ num+ "\nCaracteres: "+car);
}
}
Número 1:268
Número 2:135
Número 3:4802
Número 4:579
Número 5:125
Son números que cumplen con tener solo cifras pares: 268+4802=
(268+4802)/2=2535
Son números que cumplen con tener solo cifras impares: 135+579= 714
using System;
class Program {
static void Main(string[] args) {
Console.Write("¿Cuántos números va a ingresar? > ");
int d = int.Parse(Console.ReadLine());
int sp=0;
int sip=0;
int cont=0;
string cp="";
string cip="";
for(int i=1;i<d+1;i++){
Console.Write("Numero {0} > ",i);
int x = int.Parse(Console.ReadLine());
if(esPar(x)){
sp+=x;
cont++;
cp=cp+" "+x;
}
if(esImpar(x)){
sip+=x;
cip=cip +" "+x;
}
}
Console.WriteLine("Cifras pares>{3} --> {0}/{1}
={2}",sp,cont,sp/cont,cp);
Console.WriteLine("Cifras impares>{1} ={0}",sip,cip);
}
static bool esPar(int x){
bool xb=true;
while(x>0){
if((x%10)%2 == 0){
x=x/10;
}else{
xb=false;
break;
}
}
return xb;
}
static bool esImpar(int x){
bool xb=true;
while(x>0){
if((x%10)%2 != 0){
x=x/10;
}else{
xb=false;
break;
}
}
return xb;
}
}