Me suena haber visto esto en otra parte.
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
#include <iostream>
using namespace std;
int Big(int,int);
main()
{
int numeros[9];
int mayor=0;
for (int i=0;i<=9;i++)
{
cout<<"Introduzca numero " << (i+1) << " : ";
cin>>numeros[i];
cout<<"\n";
}
cout<<"El mayor de los dos primeros es: " << Big(numeros[0],numeros[1]);
for (int a=0;a<10;a++)
{
mayor=Big(mayor,numeros[a]);
}
cout<<"\nEl mayor de todos es: " << mayor << " \n";
system("pause");
}
int Big(int x,int y)
{
if (x>y)
{
return x;
}
else if (y>x)
{
return y;
}
else
{
return x;
}
}
Module Ejercicio
Sub Main()
Dim numeros(14) As Integer
Dim pares As String = "" : Dim impares As String = ""
Dim veces, i As Integer
While numeros.Length > veces
Console.WriteLine("Introduzca numero " & (veces + 1) & ": ")
numeros(veces) = Console.ReadLine
veces += 1
End While
For i = 0 To numeros.Length - 1
If numeros(i) Mod 2 = 0 Then
If i = numeros.Length - 1 Then
pares = pares & numeros(i)
Else
pares = pares & numeros(i) & " - "
End If
Else
If i = numeros.Length - 1 Then
impares = impares & numeros(i)
Else
impares = impares & numeros(i) & " - "
End If
End If
Next
Console.WriteLine("Pares: " & pares)
Console.WriteLine("Impares: " & impares)
Console.ReadLine()
End Sub
End Module
Imports classlibrary1.Fracciones
Module module1
Sub main()
Console.WriteLine((Fracciones.Lectura.tografico(Fracciones.Operaciones.FraccionIrreductible(Fracciones.Lectura.tofraccion(1024, 512)))))
Console.ReadLine()
End Sub
End Module
Namespace Fracciones
Public Class Operaciones
Shared Function SumaFracciones(ByVal n1 As Integer, ByVal d1 As Integer, ByVal n2 As Integer, ByVal d2 As Integer) As String
Dim nn As Integer = (n1 * d2) + (n2 * d1), dn As Integer = d1 * d2
Return Str(nn) + "/" + Str(dn)
End Function
Shared Function RestaFracciones(ByVal n11 As Integer, ByVal d11 As Integer, ByVal n22 As Integer, ByVal d22 As Integer) As String
Dim nn As Integer = (n11 * d22) - (n22 * d11), dn As Integer = d11 * d22
Return Str(nn) + "/" + Str(dn)
End Function
Shared Function MultiplicarFracciones(ByVal n111 As Integer, ByVal d111 As Integer, ByVal n222 As Integer, ByVal d222 As Integer) As String
Dim nn As Integer = (n111 * n222), dn As Integer = (d111 * d222)
Return Str(nn) + "/" + Str(dn)
End Function
Shared Function DividirFracciones(ByVal n1111 As Integer, ByVal d1111 As Integer, ByVal n2222 As Integer, ByVal d2222 As Integer) As String
Dim nn As Integer = (n1111 * d2222), dn As Integer = (n1111 * n2222)
Return Str(nn) + "/" + Str(dn)
End Function
Shared Function Fraccion2Decimal(ByVal numerador As Integer, ByVal denominador As Integer)
Return numerador / denominador
End Function
Shared Function FraccionIrreductible(ByVal fraccion As Integer()) As Integer()
Dim n As Integer = 2
While n <= Math.Max(fraccion(0), fraccion(1))
If fraccion(0) Mod n = 0 And fraccion(1) Mod n = 0 Then
fraccion(0) /= n
fraccion(1) /= n
End If
n += 1
End While
n = 2
n += 1
While n <= Math.Max(fraccion(0), fraccion(1))
If fraccion(0) Mod n = 0 And fraccion(1) Mod n = 0 Then
fraccion(0) /= n
fraccion(1) /= n
End If
n += 1
End While
Return fraccion
End Function
End Class
Public Class Lectura
Shared Function tofraccion(ByVal x As Integer, ByVal y As Integer) As Integer()
Dim newarray() As Integer = {Int(x), Int(y)}
Return newarray
End Function
Shared Function tografico(ByVal fraccion As Integer()) As String
Return fraccion(0) & "/" & fraccion(1)
End Function
End Class
End Namespace