Professional Documents
Culture Documents
///**************************************************************************///
///**************************************************************************///
void intercambiar( int v[], int v1[], short n, short m ) {
int i = 0;
int aux, x;
while ( ( i < n ) || ( i < m ) ) {
aux = v[ i ];
//x = v[ i ];
//v1[ i ] = aux;
v[ i ] = v1[ i ];
v[ i ] = x;
i++;
}
}
///**************************************************************************///
///************* EJERCICIOS DEL PRÁCTICO # 1 DEL CURSO DE VERANO ************///
///**************************************************************************///
float promedio( int v[], int n ) {
int sum = 0;
int i = 0;
float prom = 0;
while ( i < n ) {
sum = sum + v[ i ];
i++;
}
prom = sum / n;
return ( prom );
}
//------------------------------------------------------------------------------
void concatenar( int v[], int v1[], int n, int m, int vx[], int &k ) {
for ( int k = 0; k < n; k++ ) {
vx[ k ] = v[ k ];
}
for ( int i = 1; i <= n; i++ ) {
vx[ k + 1 ] = v1[ i - 1 ];
}
k += m + 1;
}
//------------------------------------------------------------------------------
bool repetidos( int v[], int n ) {
bool bb = false;
int k = 0;
while( ( k < n ) && ( !bb ) ) {
int i = k + 1;
while ( ( i < n ) && ( !bb ) ) {
if ( v[ k ] == v[ i ] ) {
bb = true;
i++;
}
}
k++;
}
}
//------------------------------------------------------------------------------
int prodMaxMin( int v[], int n ) {
int i = 1;
int max = v[ 0 ];
int min = v[ 0 ];
while ( i < n ) {
if ( v[ i ] > max )
max = v[ i ];
if ( v[ i ] < min )
min = v[ i ];
i++;
}
return ( max * min );
}
//------------------------------------------------------------------------------
void prodCartesiano( int v[], int v1[], int n, int m, int vx[] ) {
int i = 0;
int k = 0;
while ( i < n ) {
int j = 0;
while ( j < m ) {
vx[ k ] = v[ i ];
k++;
vx[ k ] = v1[ j ];
k++;
j++;
}
i++;
}
}
//------------------------------------------------------------------------------
int hamming( int v[], int v1[], int n, int m ) {
if ( n == m ) {
int c = 0;
for ( int i = 0; i < n; i++ ) {
if ( v[ i ] != v1[ i ] )
c++;
}
return ( c );
}
}
//------------------------------------------------------------------------------
int Pro1( int n ) {
int x, y, z;
x = n; y = 0; z = 0;
while ( y < x - 1 ) {
y = y + 1; z = z + y;
}
return ( z );
}
//------------------------------------------------------------------------------
int Pro2( int n ) {
int i, j, c;
c = 0;
for ( i = 1; i <= n; i++ ) {
for ( j = 1; j <= i; j++ ) {
c = c + j;
}
}
return ( c );
}
//------------------------------------------------------------------------------
int Pro3( int v[], int n ) { // OJO : CICLO INFINITOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
int p, i, j, s;
p = 1;
i = 1;
while ( i <= n ) {
s = 0;
j = 1;
while ( j < i ) {
s = v[ j ] - s;
j = j + 1;
}
p = p * s;
}
return ( p );
}
//------------------------------------------------------------------------------
int Pro4( int v[], int n ) {
int x, i, j, k;
x = n;
i = 1;
while ( i < ( n - 2 ) ) {
for ( j = i + 1; j < n; j++ ) {
k = j + 1;
while ( k < n ) {
k = k + 1;
x = x + ( v[ i ] * v[ j ] * v[ k ] - 1 );
}
}
i = i + 1;
}
return ( x );
}
///**************************************************************************///
///************* EJERCICIOS DEL PRÁCTICO # 2 DEL CURSO DE VERANO ************///
///**************************************************************************///
//------------------------------------------------------------------------------
// # 1)
bool SumaMitades(int v[],Word a,Word b,int &p,int &s) {
bool sw;
int n;
n=b-a+1;
if ( (n==1)||(n==2)){
if(n==1){
s=s+v[b];
sw=(p==s);
}
else {
p=p+v[a];
s=s+v[b];
sw=(p==s);
}
}
else {
p=p+v[a];
s=s+v[b];
sw=SumaMitades(v,a+1,b-1,p,s);
}
return sw;
}
bool SumaMitades( int v[], int n ) { //MÁSCARA
bool sw;
int p = 0, s = 0;
if( n > 1 )
sw = ( SumaMitades( v, 0, n - 1, p, s ) );
return ( sw );
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
/*int v[ 8 ] = { 8, 2, 3, 1, 3, 5, 6 }, n = 8;
if( SumaMitades( v, n ) )
ShowMessage( " SON IGUALES " );
else
ShowMessage( "No son Iguales" );*/ //OK OK OK OK OK OK
/*int v[ 50 ], i;
int n;
String x;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* DIGITE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
if( SumaMitades( v, n ) )
ShowMessage( " SON IGUALES " );
else
ShowMessage( "No son Iguales" );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
// # 2)
bool existe( int v[], int n, int x ) {
bool bb = false;
if ( n > 0 ) {
bb = existe( v, n - 1, x );
if ( v[ n - 1 ] == x )
bb = true;
}
return ( bb );
}
bool contenido( int v[], int v1[], int n, int m ) {
int a;
bool sw = true;
if ( n > 0 ) {
sw = contenido(v,v1,n-1,m);
if ( sw ) {
a = v[n-1];
if ( existe(v1,m,a)) {
sw = true;
}
else {
sw = false;
}
}
}
return ( sw );
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
/*int v[ 3 ] = { 2, 3, 4 };
int n = 3;
int v1[ 6 ] = { 1, 2, 3, 4, 5, 6 };
int m = 6;
if ( contenido( v, v1, n, m ) )
ShowMessage( "EL VECTOR A ESTÁ EN EL VECTOR B" );
else
ShowMessage( "EL VECTOR A NO ESTÁ EN EL VECTOR B" );*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
// # 3) MUESTRA EL PRODUCTO DE DOS NÚMEROS POR SUMAS
int producto( int a , int b ) {
int p;
if ( b == 0 )
p = 0;
else
p = producto( a, b - 1 ) + a;
return ( p );
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
/*int a, b;
a = StrToInt(InputBox("** XXX VERANO XXX **", "* DIGITE UN NÚMERO: ", "0" ) );
b = StrToInt(InputBox("** XXX VERANO XXX **", "* DIGITE OTRO NÚMERO: ", "0" ) );
int prod = producto( a, b );
ShowMessage( prod );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
-
// # 4) // ELEVA UN NRO X A LA N POR MEDIO DE MULTIPLICACIÓN
float potencia( Word x, Word n ) {
float p;
if ( ( x == 0 ) && ( n == 0 ) )
throw new Exception( "ERROR" );
else
if ( n == 0 )
p = 1;
else {
p = potencia( x, n / 2 );
p = p * p;
if ( ( n % 2 ) == 1 )
p = p * x;
}
return ( p );
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
/*float p, x, n;
x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ", "0" ) )
;
n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE POTENCIA: ", "0" )
);
p = potencia( x, n );
ShowMessage( p );*/
//------------------------------------------------------------------------------
// # 5)
void casillaPar( int v[], int n, String &x ) {
if ( n == 1 )
x = IntToStr( v[ 0 ] );
else {
casillaPar( v, n-1, x );
if ( ( n - 1 ) % 2 == 0 )
x = x + "," + IntToStr( v[ n - 1 ] );
}
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
/*int v[ 5 ] = { 0, 1, 2, 3, 4 };
int n = 5;
String s;
casillaPar( v, 5, s );
ShowMessage( s );*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
// # 6)
int cantRepite( int v[], int n, int a ) {
int c;
if ( n == 0 )
c = 0;
else {
c = cantRepite( v, n - 1, a );
if ( v[ n -1 ] == a )
c++;
}
return ( c );
}
int contar(TStringGrid *v, int n, int x ) {
int c = 0;
if ( n > 0 ) {
c = contar( v, n - 1, x );
if ( v->Cells[ n - 1 ][ 0 ] == x )
c++;
}
return ( c );
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
/*int v[ 5 ] = { 2, 3, 4, 5, 5 };
int n = 5;
int x = 5, c;
c = cantRepite( v, n, x );
ShowMessage( c );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
// # 7)
int proEscalar( int v1[], int v2[], int n ) {
int prod;
if( n == 0 )
prod = 0;
else {
prod = proEscalar( v1, v2, n - 1 ) + v1[ n - 1 ] * v2[ n - 1 ];
}
return ( prod );
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO> //
/*int v1[ 3 ] = { 1, 2, 3 };
int n = 3;
int v2[ 3 ] = { 4, 5, 6 };
int m = 3;
int prod = proEscalar( v1, v2, n );
ShowMessage( prod );*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
// # 8)
bool esPalindrome( String s, int x ) {
bool bb;
char c,e;
int n = s.Length( ) - x + 1;
if ( ( n == 0 ) || ( n == 1 ) || ( n == 2 ) ) {
if ( n == 2 ) {
c = s[ n ];
e = s[ n - 1 ];
bb = ( c == e );
}
else
bb = true;
}
else {
c = s[ n ];
e = s[ x ];
s = s.SetLength( 1 );
bb = esPalindrome( s, x + 1 );
if ( bb )
bb = ( c == e );
}
return ( bb );
}
bool esPalindrome( String s ) {
bool sw;
sw = esPalindrome( s, 1 );
return ( sw );
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO> //
/*String s = EditMostrar->Text;
s = InputBox( "CADENAXXX","* DIGITE UNA CADENA :", "hola" );
if ( esPalindrome( s ) )
ShowMessage("TRUE");
else
ShowMessage("FALSE");*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
// # 10)
int ackerman( int M, int N ) {
int res;
if ( M == 0 ) {
res = N + 1;
}
else {
if ( N == 0 ) {
res = ackerman( M - 1, 1 );
}
else {
res = ackerman( M - 1, ackerman( M, N - 1 ) );
}
}
return ( res );
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO> //
/*int M, N;
M = StrToInt(InputBox("** XXX VERANO XXX **", "* DIGITE UN NÚMERO: ", "0" ) );
N = StrToInt(InputBox("** XXX VERANO XXX **", "* DIGITE OTRO NÚMERO: ", "0" ) );
int res = ackerman(M,N);
ShowMessage( res );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
// # 11)
int sumMayUlt( TStringGrid *v, int n ) {
int a,s=0;
int x;
x=StrToInt(v->Cells[n-1][0]);
if(n>1){
a=StrToInt(v->Cells[n-2][0]);
s=sumMayUlt(v,n-1);
if(a>x)
s=s+a;
}
return s;
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO> //
//ShowMessage(sumMayUlt(Vextor,Vextor->ColCount)); // OK OK OK OK OK OK
int sumMayUlt( int v[], int n ) {
int a,s=0;
int x;
x= v[n-1];
if(n>1){
a=v[n-2];
s=sumMayUlt(v,n-1);
if(a>x)
s=s+a;
}
return s;
}
//------------------------------------------------------------------------------
// # 12)
void BurbuVer( int v[], int n ) {
byte aux;
if ( n > 1 ) {
BurbuVer( v, n - 1 );
if ( v[ n - 2 ] > v[ n - 1 ] ) {
aux = v[ n - 1 ] ;
v[ n - 1 ] = v[ n - 2 ];
v[ n - 2 ] = aux;
}
}
}
void OrdenBurbuVer( Word n, int v[] ) {
if ( n > 1 ) {
BurbuVer( v, n );
OrdenBurbuVer( n - 1, v );
}
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO> //
/*int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "** VERANO **", "* DIGITE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "** VERANO **", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
OrdenBurbuVer( n, v );
for ( i = 0; i < n; i++ ) {
EditMostrar->Text = EditMostrar->Text + "-" + IntToStr( v[ i ] );
}*/ // OK OK OK OK OK OK
///**************************************************************************///
///******************************* CADENAS ******************************///
///**************************************************************************///
//------------------------------------------------------------------------------
// 1) PROGRAMA QUE VERIFICA SI ES CONSONANTE
bool esConsonante( char x ) {
bool sw = false;
if ( ( x == 'b' ) || ( x == 'c' ) || ( x == 'd' ) || ( x == 'f' ) ||
( x == 'g' ) || ( x == 'h' ) || ( x == 'j' ) || ( x == 'k' ) ||
( x == 'l' ) || ( x == 'm' ) || ( x == 'n' ) || ( x == 'p' ) ||
( x == 'q' ) || ( x == 'r' ) || ( x == 's' ) || ( x == 't' ) ||
( x == 'v' ) || ( x == 'w' ) || ( x == 'x' ) || ( x == 'y' ) ||
( x == 'z' ) )
sw = true;
return ( sw );
}
//------------------------------------------------------------------------------
// 2) PROGRAMA QUE VERIFICA SI ES VOCAL
bool esVocal( char x ) {
bool sw = false ;
if ( ( x == 'a' ) || ( x == 'e' ) || ( x == 'i' ) || ( x == 'o' ) ||
( x == 'u' ) || ( x == 'A' ) || ( x == 'E' ) || ( x == 'I' ) ||
( x == 'O' ) || ( x == 'U' ) )
sw = true;
return ( sw );
}
//------------------------------------------------------------------------------
// 3) PROGRAMA QUE ELIMINA LAS VOCALES DE UNA CADENA
void ElimVoc( String &s ) {
int n = s.Length( );
char ch;
if( n > 0 ) {
ch = s[ n ];
s.Delete( n, 1 );
ElimVoc( s );
if( !esVocal( ch ) )
s += ch;
}
}
//------------------------------------------------------------------------------
// 4) PROGRAMA QUE INVIERTE UNA CADENA
String invertirCad( String &s ) {
int n = s.Length();
if( n > 0 ) {
char x = s[ n ];
s.Delete( n, 1 );
invertirCad( s );
s.Insert( x, 1 );
}
return ( s );
}
//------------------------------------------------------------------------------
// 5) PROGRAMA QUE CUENTA LA CANTIDAD DE PALABRAS DE UNA CADENA
int contarPal( String &s ) {
int n, c;
s = s.Trim( );
n = s.Length( );
s = s + ' ';
if ( n == 0 )
c = 0;
else {
int pos = s.Pos( ' ' );
s.Delete( 1, pos );
c = contarPal( s );
c++;
}
return ( c );
}
int contPalabras( String s ) {
int c, n;
char x;
n = s.Length( );
if ( n == 0 ) //Primer Caso Base
c = 0;
else
if ( n == 1 ) { //Segundo Caso Base
if ( s[ 1 ] == ' ' )
c = 0;
else
c = 1;
}
else {
x = s[ n ];
s.SetLength( n - 1 );
c = contPalabras( s );
if ( ( x != ' ' ) && ( s[ n - 1 ] == ' ' ) )
c++;
}
return ( c );
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
/*String s = EditMostrar->Text;
s = ( InputBox( "CADENAXXX","* DIGITE UNA CADENA :", "" ) );
int x = contPalabras( s ); //CONTAR LA CANTIDAD DE PALABRAS QUE TENGAN LA L
ETRA 'A'
EditMostrar->Text = EditMostrar->Text + ( x );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 6) PROGRAMA QUE SEPARA LAS VOCALES Y CONSONANTES DE UNA CADENA
void separaVocCon( String s, String &s1, String &s2 ) {
int n = s.Length( );
char ch;
s.Trim( );
if ( n > 0 ) {
ch = s[ n ];
s.Delete( n, 1 );
separaVocCon( s, s1, s2 );
if ( esVocal( ch ) ) {
s1 += ch;
}
else
if ( ch != ' ' ) {
s2 += ch;
}
}
}
//------------------------------------------------------------------------------
// 7) PROGRAMA QUE CUENTA LAS VOCALES QUE ESTÁN DELANTE DE UNA CONSONANTE
int contVocCon( String s ) {
int n = s.Length( );
int c = 0;
if ( n < 2 )
c = 0;
else {
char x = s[ n ];
s.Delete( n, 1 );
c = contVocCon( s );
if ( ( esVocal( s[ n - 1 ] ) ) && ( esConsonante( x ) ) )
c++;
}
return ( c );
}
//------------------------------------------------------------------------------
// 8) PROGRAMA QUE CUENTA LA CANTIDAD DE VOCALES DE UNA CADENA
int contVocales( String s ) {
int a = 0;
int n = s.Length( );
if ( n > 0 ) {
char ch = s[ n ];
s.Delete( n, 1 );
a = contVocales( s );
if ( esVocal( ch ) )
a++;
}
return ( a );
}
int cantidadVocales( String s ) {
int c, n;
char x;
n = s.Length( );
if ( n == 0 )
c = 0;
else {
x = s[ n ];
s.SetLength( n - 1 );
c = cantidadVocales( s );
if ( esVocal( x ) )
c++;
}
return ( c );
}
//------------------------------------------------------------------------------
// 9) PROGRAMA QUE ELIMINA LOS ESPACIOS DE UNA CADENA
void ElimEsp( String &s ) {
int n = s.Length( );
String x = ' ';
if ( n > 0 ) {
x = s[ n ];
s.Delete( n, 1 );
ElimEsp( s );
if ( x != ' ' )
s = s + x;
}
}
//------------------------------------------------------------------------------
// 10) PROGRAMA QUE ELIMINA UN CARACTER DE UNA CADENA
void ElimCar( String &s, char c ) {
int n = s.Length( );
char x = ' ';
if ( n > 0 ) {
x = s[ n ];
s.Delete( n, 1 );
ElimCar( s, c );
if ( x != c )
s = s + x;
}
}
//------------------------------------------------------------------------------
// 11) PROGRAMA QUE MUESTRA LA PALABRA LARGA DE UNA CADENA
String palExt( String &s ) {
int n;
String b, c;
s = s.Trim( );
n = s.Length( );
s = s + ' ';
if ( n == 0 ) {
return ( "" );
}
else {
int pos = s.Pos( ' ' );
c = s.SubString( 1, pos - 1 );
s.Delete( 1, pos );
b = palExt( s );
if ( c.Length( ) >= b.Length( ) )
b = c;
}
return ( b );
}
//------------------------------------------------------------------------------
// 12) PROGRAMA QUE CUENTA CANTIDAD DE PALABRAS QUE TENGA LA LETRA 'A'
int contarPalabras( String &s ) {
int n, c;
String s1;
s = s.Trim( );
n = s.Length( );
s = s + ' ';
if ( n == 0 )
return ( 0 );
else {
int pos = s.Pos( ' ' );
s1 = s.SubString( 1, pos - 1 );
s.Delete( 1, pos );
c = contarPalabras( s );
n = s1.Length( );
int i = 1;
bool sw = false;
while ( ( i <= n ) && ( sw == false ) ) {
if ( s1[ i ] == 'a' ) {
sw = true;
c++;
}
i++;
}
}
return ( c );
}
//------------------------------------------------------------------------------
// 13) PROGRAMA QUE MUESTRA SI SE ENCUENTRA LA LETRA 'A' EN LA CADENA
bool esta( String &s ) {
int n = s.Length( );
bool sw;
if ( n == 0 ) {
sw = false;
}
else {
int x = s[ n ];
s.Delete( n, 1 );
sw = esta( s );
if ( x == 'a' )
sw = true;
}
return ( sw );
}
//------------------------------------------------------------------------------
// 14) PROCEDIMIENTO QUE ELIMINA LAS VOCALES DE UNA CADENA
void elimVocales( String &s ) {
int n;
char x;
String vocal = "aeiouAEIOUáéíóúàèìòùäëïöüâêîôû";
n = s.Length( );
if ( n > 0 ) {
x = s[ n ];
s.SetLength( n - 1 );
elimVocales( s );
if ( vocal.Pos( x ) == 0 )
s = s + x;
}
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
/*String s=EditMostrar->Text;
s = ( InputBox("CADENAXXX","* DIGITE UNA CADENA :", "" ) );
elimVocales( s ); //ELIMINAR LAS VOCALES DE UNA CADENA
EditMostrar->Text = EditMostrar->Text+( s );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 15) FUNCIÓN QUE MUESTRA LA CANTIDAD DE PALABRAS QUE TENGAN AL MENOS UNA LETRA '
A'
void contPar( String s, int &c, bool hay ) {
int n;
char x;
n = s.Length( );
if ( n == 0 ) {
c = 0;
hay = false;
}
else {
x = s[ n ];
s.SetLength( n - 1 );
contPar( s, c, hay );
if ( ( x == 'a' || x == 'A') && ( !hay ) ) {
c++;
hay = true;
}
else
if ( x == ' ' ) {
hay = false;
}
}
}
/*int contarPalA( String s ) {
int c;
bool sw;
contarPalA( s,c,sw ); // OOOOOOOOOOOOOOOOJJJJJJJJJJJJJJJJJJJJJJOOOOOOOOOO
return ( c );
} */
//------------------------------------------------------------------------------
bool Palin(String s,int a,int b)
{ int n=(b-a+1)/2; bool f; Char x,y;
if(n==0)
f=true;
else
{ x=s[a]; y=s[b];
if(Palin(s,a+1,b-1)&&x==y)
f=true;
else
f=false;
}return f;
}
bool Palin(String s)
{ int a,b; bool f;
b=s.Length();
if(Palin(s,1,b))
f=true;
else
f=false;
return f;
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
/*String cad=InputBox("",""," ");
if(Palin(cad))
ShowMessage("Es Palindrome");
else
ShowMessage("No es Palindrome");*/
//------------------------------------------------------------------------------
bool EstalaVoc(String s)
{ bool b; char p; String voc="aeiouAEIOU";
int n=s.Length();
if(n==0)
b=false;
else
{ p=s[n];
s=s.SetLength(n-1);
if(voc.Pos(p)>0)
b=true;
else
b=EstalaVoc(s);
}
return b;
}
int ContarPal(String s) // CONTAR LAS PALABRAS SIN VOCALES
{ int c; int n=s.Length();
if(n==0)
c=0;
else
{ char p=s.Pos(' ');
if(p==0)
p=n;
String aux=s.SubString(1,p);
s=s.SubString(p+1,n-p);
c=ContarPal(s);
if(!EstalaVoc(aux))
c++;
}
return c;
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
/*String s=InputBox("","","");
ShowMessage("Las Palabras sin vocal son: "+IntToStr(ContarPal(s)));*/
//------------------------------------------------------------------------------
// ESTÁ LA LETRA 'A'
bool estaVoc(String s)
{ int n; char p; bool b;
n=s.Length();
if(n==0)
b=false;
else
{ p=s[n];
s.SetLength(n-1);
if(estaVoc(s)||p=='a')
b=true;
else
b=false;
}return b;
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
/*String cad=Edit1->Text;
if(estaVoc(cad))
ShowMessage("Esta");
else
ShowMessage("No esta");*/
//------------------------------------------------------------------------------
// CONTAR LAS PALABRAS QUE TENGAN LA LETRA 'A'
int ContarPalconVoc(String s)
{ int c,n; char p;
n=s.Length();
if(n==0)
c=0;
else
{ if(n==1)
{ if(s[1]=='a')
c=1;
else
c=0;
}
else
{ int a=s.Pos(' ');
if(a==0)
a=n;
String cad=s.SubString(1,a-1);
s=s.SubString(a+1,n-a);
c=ContarPalconVoc(s);
if(estaVoc(cad))
c++;
}
}
return c;
}
// < AQUÍ ESTÁ SU LLAMADA AL MÉTODO > //
//ShowMessage(IntToStr(ContarPalconVoc(Edit1->Text)));
///**************************************************************************///
///************ DESDE AQUÍ EMPIEZO A LLAMAR A TODAS MIS FUNCIONES ***********///
///********** POR AQUÍ ACCEDO DIRECTO A LAS FUNCIONES DESDE EL MENÚ *********///
///**************************************************************************///
//------------------------------------------------------------------------------
void __fastcall TForm1::Fibonacci1Click(TObject *Sender) {
short a;
a = StrToInt( InputBox( "* SERIE FIBONACCI", "* INGRESE UN NÚMERO: ", "0" ) );
EditMostrar->Text = Fibo( a );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Ascendentes1Click(TObject *Sender) {
byte a;
a = StrToInt( InputBox( "* PRIMEROS N NÚMEROS NATURALES", "* INGRESE UN NÚMERO: ",
"0" ) );
Mostrar( a );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Descendentes1Click(TObject *Sender) {
byte a;
a = StrToInt( InputBox( "* PRIMEROS N NÚMEROS NATURALES", "* INGRESE UN NÚMERO: ",
"0" ) );
Mostrar1( a );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Pares1Click(TObject *Sender) {
byte a;
a = StrToInt( InputBox( "* PRIMEROS N NÚMEROS PARES", "* INGRESE UN NÚMERO: ", "0"
) );
MostrarPares( a );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Impares1Click(TObject *Sender) {
byte a;
a = StrToInt( InputBox( "* PRIMEROS N NÚMEROS IMPARES", "* INGRESE UN NÚMERO: ", "
0" ) );
MostrarImpares( a );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Digitos1Click(TObject *Sender) {
int a;
a = StrToInt( InputBox( "* SUMA DE LOS DÍGITOS DE UN NÚMERO", "* INGRESE UN NÚMERO:
", "0" ) );
( *EditMostrar ).Text = SumaDigitos( a );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::DigitoPares1Click(TObject *Sender) {
Cardinal a;
a = StrToInt( InputBox( "* ELIMINAR DÍGITOS PARES DE UN NÚMERO", "* INGRESE UN NÚMER
O: ", "0" ) );
EliminarPares( a );
ShowMessage( a );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Pares2Click(TObject *Sender) {
int a;
a = StrToInt( InputBox( "* SUMA DE LOS DÍGITOS PARES DE UN NÚMERO", "* INGRESE UN
NÚMERO: ", "0" ) );
( *EditMostrar ).Text = SumaDigitosPares( a );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::ParesImpares1nro1Click(TObject *Sender) {
Cardinal x,p,i;
x = StrToInt( InputBox( "* SEPARAR DÍGITOS PARES-IMPARES DE UN NÚMERO", "* INGRESE
UN NÚMERO: ", "0" ) );
Sep_Imp_Par( p, i, x );
ShowMessage( " [ " +IntToStr( p ) +'|'+ IntToStr( i ) + " ] " );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::BtnSepararClick(TObject *Sender) {
Cardinal x, y, z;
EditMostrar->Clear( );
x = StrToInt( InputBox( "* SEPARAR PAR - IMPAR", "* INGRESE UN NÚMERO: ", "0" )
);
y = StrToInt( InputBox( "* SEPARAR PAR - IMPAR", "* INGRESE OTRO NÚMERO: ", "0"
) );
Edit1->Text = x;
Edit2->Text = y;
juntar( x, y, z );
if ( z <= 999999999 ) {
EditMostrar->Text = z;
Sep_Imp_Par( x, y, z );
}
Edit1->Text = x;
Edit2->Text = y;
}
//------------------------------------------------------------------------------
void __fastcall TForm1::BurbujaClick(TObject *Sender) {
int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "* ORDENAR UN VECTOR POR BURBUJA", "* DIGITE DIMENSIÓN:
", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "* ORDENAR UN VECTOR POR BURBUJA", "* VALOR: ",
"0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
OrdenarBurbu( n, v );
for ( i = 0; i < n; i++ ) {
EditMostrar->Text = EditMostrar->Text + "-" + IntToStr( v[ i ] );
}
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Juntar2Nro1Click(TObject *Sender) {
Cardinal x, y, z;
EditMostrar->Clear( );
x=StrToInt( InputBox( "* JUNTAR LOS DÍGITOS DE DOS NÚMEROS", " * INGRESE UN NÚMERO:
", "0" ) );
y=StrToInt( InputBox( "* JUNTAR LOS DÍGITOS DE DOS NÚMEROS", " * INGRESE OTRO NÚMERO
: ", "0" ) );
Edit1->Text = x;
Edit2->Text = y;
juntar( x, y, z );
if ( z <= 999999999 )
EditMostrar->Text = z;
else
EditMostrar->Text = "NO SE PUDO JUNTAR";
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Potenciaxn1Click(TObject *Sender) {
Word x, n;
x = StrToInt( InputBox( "* POTENCIA X ^ N", "* INGRESE UN NÚMERO: ", "0" ) );
n = StrToInt( InputBox( "* POTENCIA X ^ N", "* INGRESE POTENCIA: ", "0" ) );
EditMostrar->Text = FloatToStr( Potencia( x, n ) );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Burbuja1Click(TObject *Sender) {
int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "* ORDENAR UN VECTOR POR BURBUJA", "* DIGITE DIMENSIÓN:
", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "* ORDENAR UN VECTOR POR BURBUJA", "* VALOR: ",
"0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
OrdenarBurbu( n, v );
for ( i = 0; i < n; i++ ) {
EditMostrar->Text = EditMostrar->Text + "-" + IntToStr( v[ i ] );
}
}
//------------------------------------------------------------------------------
void __fastcall TForm1::SumaDgitosPares1Click(TObject *Sender) {
int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "* SUMA DE LOS DÍGITOS DE UN VECTOR", "* INGRESE DIMENSIÓN
: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "* SUMA DE LOS DÍGITOS DE UN VECTOR", "* VALOR: "
, "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
EditMostrar->Text = IntToStr( SumaV( v, n ) );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::SumaDgitos1Click(TObject *Sender) {
int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "* SUMA DE LOS DÍGITOS PARES DE UN VECTOR", "* INGRESE D
IMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "* SUMA DE LOS DÍGITOS PARES DE UN VECTOR", "* VA
LOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
EditMostrar->Text = IntToStr( sumaPares( v, n ) );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::SumaDgitosImpares1Click(TObject *Sender) {
int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "* SUMA DE LOS DÍGITOS IMPARES DE UN VECTOR", "* INGRESE
DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "* SUMA DE LOS DÍGITOS IMPARES DE UN VECTOR", "*
VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
EditMostrar->Text = IntToStr( SumaImpares( v, n ) );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::PromedioDgitos1Click(TObject *Sender) {
int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "* PROMEDIO DE LOS DÍGITOS DE UN VECTOR", "* INGRESE DIM
ENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "* PROMEDIO DE LOS DÍGITOS DE UN VECTOR", "* VALO
R: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
EditMostrar->Text = FloatToStr( PromedioV( v, n ) );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::MayorDgito1Click(TObject *Sender) {
int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "* MAYOR DÍGITO DE UN VECTOR", "* INGRESE DIMENSIÓN: ", "0
" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "* MAYOR DÍGITO DE UN VECTOR", "* VALOR: ", "0" )
);
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
EditMostrar->Text = IntToStr( Mayor( v, n ) );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Clear1Click(TObject *Sender) {
Edit1->Clear( );
Edit2->Clear( );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::OrdenarBurbuja1Click(TObject *Sender) {
Cardinal a;
a = StrToInt( InputBox( "* ORDENAR DÍGITOS DE UN NÚMERO POR BURBUJA", "* INGRESE U
N NÚMERO: ", "0" ) );
OrdenarX( a );
ShowMessage( a );
}
//------------------------------------------------------------------------------
/*void __fastcall TForm1::OrdenarInsertar1Click(TObject *Sender) {
Cardinal a;
a = StrToInt(InputBox("* ORDENAR LOS DÍGITOS DE UN NÚMERO POR INSERCIÓN","* INGRESE
UN NÚMERO: "," "));
Ordenar( a );
ShowMessage( a ); //ALGO ESTA MALLLLLLLLLLLLLLL
} */
//------------------------------------------------------------------------------
void __fastcall TForm1::Exit1Click(TObject *Sender) {
Application->Terminate( );
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BtnSalirClick(TObject *Sender) {
Application->Terminate( );
}
//------------------------------------------------------------------------------
void __fastcall TForm1::TimerAutorTimer(TObject *Sender) {
LbAutor->Visible =!LbAutor->Visible;
ImgCamba->Visible = !ImgCamba->Visible;
ImgkoRn->Visible = !ImgkoRn->Visible;
}
//------------------------------------------------------------------------------
void __fastcall TForm1::TimerResultadoTimer(TObject *Sender) {
LblResultado->Visible = !LblResultado->Visible;
}
//------------------------------------------------------------------------------
void __fastcall TForm1::TimerTituloTimer(TObject *Sender) {
String x, s = "";
s = Caption;
char ch = s[ 1 ];
s.Delete( 1, 1 );
s.Insert( ch, s.Length( ) );
Caption = s;
x += 11;
/// ESTE CÓDIGO ME PERMITIRÁ MOVER EL TÍTULO DE LA VENTANA FORM1 ///
/*String cad, aux; //var cad,aux:string;
cad = Form1->Caption; //cad:=FrmExplorador.Caption;
aux = cad[cad.Length()]; //aux:=cad[length(cad)];
delete(cad, cad.Length(),1);//Delete(cad,length(cad),1);
cad = aux + cad; //cad:=aux+cad;
Form1->Caption = cad;*/ //FrmExplorador.Caption:=cad;
}
//------------------------------------------------------------------------------
void __fastcall TForm1::InvertirElementos1Click(TObject *Sender) {
int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "* INVERTIR ELEMENTOS DE UN VECTOR", "* DIGITE DIMENSIÓN
: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "* INVERTIR ELEMENTOS DE UN VECTOR", "* VALOR:
", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
Invertir( v, n );
for ( i = 0; i < n; i++ ) {
EditMostrar->Text = EditMostrar->Text + "-" + IntToStr( v[ i ] );
} //v[6]={1,3,8,9,10,7};
}
//------------------------------------------------------------------------------
void __fastcall TForm1::BusquedaBinaria1Click(TObject *Sender) {
int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "* BUSQUEDA BINARIA", "* DIGITE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "* BUSQUEDA BINARIA", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
BusBin( v, n, 10 );
for ( i = 0; i < n; i++ ) {
if ( BusBin( v, n, 10 ) ) // OJO MUESTRA LAS VECES DE DIGITOS DE
L VECTOR //
ShowMessage( "SE ENCUENTRA EL VALOR =)" );
else
ShowMessage( "NO SE ENCUENTRA EL VALOR =(" );
}
}
//------------------------------------------------------------------------------
void __fastcall TForm1::BusBinariaClick(TObject *Sender) {
int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "* BUSQUEDA BINARIA", "* DIGITE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "* BUSQUEDA BINARIA", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
BusBin( v, n, 10 );
for ( i = 0; i < n; i++ ) {
if ( BusBin( v, n, 10 ) ) // OJO MUESTRA LAS VECES DE DIGITOS DE
L VECTOR //
ShowMessage( "SE ENCUENTRA EL VALOR =)" );
else
ShowMessage( "NO SE ENCUENTRA EL VALOR =(" );
}
}
//-----------------------------------------------------------------------------
void __fastcall TForm1::QuickSort1Click(TObject *Sender) {
int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "* ORDENAR UN VECTOR POR QUICKSORT", "* DIGITE DIMENSIÓN
: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "* ORDENAR UN VECTOR POR QUICKSORT", "* VALOR:
", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
QuickSort(v,n);
//OrdenarBurbu( n, v );
for ( i = 0; i < n; i++ ) {
EditMostrar->Text = EditMostrar->Text + "-" + IntToStr( v[ i ] );
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CargaRandomizeClick(TObject *Sender) {
Word i, n ;
n = StrToInt( InputBox( "* CARGA RANDOMIZE", "* INGRESE DIMENSIÓN: ", "0" ) );
Vextor->ColCount = n;
Randomize( );
for ( i = 0; i < n; i++ ) {
Vextor->Cells[ i ][ 0 ] = random( 20 );
}
}
//------------------------------------------------------------------------------
///**************************************************************************///
///******************* LLAMADOS A LOS MÉTODOS RECURSIVOS ********************///
///**************************************************************************///
void __fastcall TForm1::BTNRECURSIVOClick(TObject *Sender) {
//****************************************************************************//
//********* LLAMADOS A TODOS LOS MÉTODOS DEL PRÁCTICO # 2 DE VERANO **********//
//****************************************************************************//
//------------------------------------------------------------------------------
// 1)
/*int v[ 8 ] = { 8, 2, 3, 1, 3, 5, 6 }, n = 8;
if( SumaMitades( v, n ) )
ShowMessage( " SON IGUALES " );
else
ShowMessage( "No son Iguales" );*/ //OK OK OK OK OK OK
/*int v[ 50 ], i;
int n;
String x;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* DIGITE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
if( SumaMitades( v, n ) )
ShowMessage( " SON IGUALES " );
else
ShowMessage( "No son Iguales" );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 2)
/*int x = StrToInt(InputBox("","",""));
if ( existe(v,n,x))
ShowMessage("SI");
else
ShowMessage("NO");*/ //
/*int v[ 3 ] = { 2, 3, 4 };
int n = 3;
int v1[ 6 ] = { 1, 2, 3, 4, 5, 6 };
int m = 6;
if ( contenido( v, v1, n, m ) )
ShowMessage( "EL VECTOR A ESTÁ EN EL VECTOR B" );
else
ShowMessage( "EL VECTOR A NO ESTÁ EN EL VECTOR B" );*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 3) MUESTRA EL PRODUCTO DE DOS NÚMEROS POR SUMAS
/*int a, b;
a = StrToInt(InputBox("** XXX VERANO XXX **", "* DIGITE UN NÚMERO: ", "0" ) );
b = StrToInt(InputBox("** XXX VERANO XXX **", "* DIGITE OTRO NÚMERO: ", "0" ) );
int prod = producto( a, b );
ShowMessage( prod );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 4)
/*float p, x, n;
x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ", "0" ) )
;
n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE POTENCIA: ", "0" )
);
p = potencia( x, n );
ShowMessage( p );*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 5) MOSTRAR ELEMENTOS DEL VECTOR DE LAS CASILLAS PARES
/*int v[ 5 ] = { 0, 1, 2, 3, 4 };
int n = 5;
String s;
casillaPar( v, 5, s );
ShowMessage( s );*/ // OK OK OK OK OK OK
/*int v[ 50 ], i;
int n;
String s;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* DIGITE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
casillaPar( v, n, s );
EditMostrar->Text = EditMostrar->Text + "," + s;*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 6) CANTIDAD QUE SE REPITE
/*int v[ 5 ] = { 2, 3, 4, 5, 5 };
int n = 5;
int x = 5, c;
c = cantRepite( v, n, x );
ShowMessage( c );*/ //OK OK OK OK OK OK
/*int v[ 50 ], i;
int n, x;
int a, c;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* DIGITE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
x = StrToInt( InputBox( "VEXXXTOR", "* DIGITE UN NÚMERO: ", "0" ) );
c = cantRepite( v, n, x );
EditMostrar->Text = EditMostrar->Text + IntToStr( c );*/ // OK OK OK OK OK OK
/*int x = StrToInt(InputBox( "** XXX VERANO XXX **","* DIGITE UN NÚMERO: ","0" )
);
int c = contar( Vextor, Vextor->ColCount, x );
ShowMessage( x );*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 7)
/*int v1[ 3 ] = { 1, 2, 3 };
int n = 3;
int v2[ 3 ] = { 4, 5, 6 };
int m = 3;
int prod = proEscalar( v1, v2, n );
ShowMessage( prod );*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 8)
/*String s = EditMostrar->Text;
s = InputBox( "CADENAXXX","* DIGITE UNA CADENA :", "hola" );
if ( esPalindrome( s ) )
ShowMessage("TRUE");
else
ShowMessage("FALSE");*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 10)
/*int M, N;
M = StrToInt(InputBox("** XXX VERANO XXX **", "* DIGITE UN NÚMERO: ", "0" ) );
N = StrToInt(InputBox("** XXX VERANO XXX **", "* DIGITE OTRO NÚMERO: ", "0" ) );
int res = ackerman(M,N);
ShowMessage( res );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 11)
//ShowMessage(sumMayUlt(Vextor,Vextor->ColCount));// // OK OK OK OK OK OK
/*int v[ 50 ], i;
int n, sum;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* DIGITE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
sum = sumMayUlt( v, n);
EditMostrar->Text = EditMostrar->Text +IntToStr( sum );*/ // OK OK OK OK OK O
K
//------------------------------------------------------------------------------
// 12)
/*int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "** VERANO **", "* DIGITE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "** VERANO **", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
OrdenBurbuVer( n, v );
for ( i = 0; i < n; i++ ) {
EditMostrar->Text = EditMostrar->Text + "-" + IntToStr( v[ i ] );
}*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
// 14)
/*int v[] = { 8, 4, 2, 5, 6, 1, 3, 9 };
Word n = 8;
int t = posMayor( v, n );
ShowMessage( t );
selection( v, t );
for( int i = 0; i < n; i++ ) {
ShowMessage( v[ i ] ); // OK OK OK OK OK OK
}*/
//------------------------------------------------------------------------------
// 15)
/*int a,b,v[ 7 ] = { 1, 3, 5, 8, 9, 10, 6 };
int n = 7;
MergeSort( v, a, b );
ShowMessage( "[" + VecToStr( v, n ) + "]" );*/ //malllllllllllllllllllllllllll
ll
///**************************************************************************///
///******************************* CADENAS ******************************///
///**************************************************************************///
//------------------------------------------------------------------------------
/*String s = "Homero raro";
ShowMessage(palExt(s));*/ //OK
/*String s=EditMostrar->Text;
s = ( InputBox("CADENAXXX","* DIGITE UNA CADENA :", "" ) );
palExt( s ); //MUESTRA LA PALABRA MAS LARGA DE UNA CADENA ojoooooooooooooo
EditMostrar->Text = EditMostrar->Text+(s);*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
/* int v[5]={9,2,3,4,5};
int max,min; mallllllllllllllllllllllllllll
MaxMin(v,max,min,5);
ShowMessage(IntToStr(max)+"/"+IntToStr(min)); */
//------------------------------------------------------------------------------
/*String s = "adf dba bfei";
ElimVoc(s);
ShowMessage(s);*/ //OK
/*String s=EditMostrar->Text;
s = ( InputBox("CADENAXXX","* DIGITE UNA CADENA :", "" ) );
ElimVoc(s); //ELIMINA LAS VOCALES DE UNA CADENA
EditMostrar->Text = EditMostrar->Text+(s);*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*String s = "hola a todos";
String s1,s2;
separaVocCon(s,s1,s2);
ShowMessage(s1+"-"+s2);*/ //OK
/*String s,s1,s2=EditMostrar->Text;
s = ( InputBox("CADENAXXX","* DIGITE UNA CADENA :", "" ) );
separaVocCon(s,s1,s2); //SAPARA LAS VOCALES DE LAS CONSONANTES DE UNA CADEN
A
EditMostrar->Text = EditMostrar->Text+(s1+"-"+s2);*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*String s = "hola a todos";
invertirCad(s);
ShowMessage(s);*/ //OK
/*String s=EditMostrar->Text;
s = ( InputBox("CADENAXXX","* DIGITE UNA CADENA :", "" ) );
invertirCad( s ); //INVERTIR UNA CADENA
EditMostrar->Text = EditMostrar->Text+(s);*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*String s="hola a todos";
ShowMessage(contVocales(s));*/ //OK
/*String s="hola a todos";
int a=contVocales(s);
ShowMessage(a); */
/*String s = EditMostrar->Text;
s = ( InputBox( "CADENAXXX","* DIGITE UNA CADENA :", "" ) );
int x = contVocales( s ); //CONTAR LA VOCALES DE UNA CADENA
EditMostrar->Text = EditMostrar->Text + ( x );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*String s = "ddsdsffgsdf";
ElimCar(s,'d');
ShowMessage(s);*/ //OK
/*String s=EditMostrar->Text;
s = ( InputBox("CADENAXXX","* DIGITE UNA CADENA :", "" ) );
ElimCar(s,'a'); //ELIMINAR UN CARACTER DE UNA CADENA
EditMostrar->Text = EditMostrar->Text+(s);*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*String s = "ddsf sfvdfg dfbh";
ElimEsp(s);
ShowMessage(s);*/ //OK
/*String s=EditMostrar->Text;
s = ( InputBox( "CADENAXXX", "* DIGITE UNA CADENA :", "" ) );
ElimEsp( s ); //ELIMINAR LOS ESPACIOS DE UNA CADENA
EditMostrar->Text = EditMostrar->Text + ( s );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*String s="hola asd";
ShowMessage(contarPal(s));*/ //OK
/*String s = EditMostrar->Text;
s = ( InputBox( "CADENAXXX","* DIGITE UNA CADENA :", "" ) );
int x = contarPal( s ); //CONTAR LAS PALABRAS DE UNA CADENA
EditMostrar->Text = EditMostrar->Text + ( x );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
//CONTAR VOCALES CONSONANTES.......
/*String s="hola amigos ed hoy";
int d=contVocCon(s);
ShowMessage(d);*/
/*String s = EditMostrar->Text;
s = ( InputBox( "CADENAXXX","* DIGITE UNA CADENA :", "" ) );
int x = contVocCon( s ); //CONTAR CUANTAS VOCALES-CONSONANTES HAY DE UNA CA
DENA
EditMostrar->Text = EditMostrar->Text + ( x );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*String s="hola a todos";
ShowMessage(contarPalabras(s));*/ //OK
/*String s="hola a todas las amigas de alan";
int a=contarPalabras(s);
ShowMessage(a);*/ //OK
/*String s = EditMostrar->Text;
s = ( InputBox( "CADENAXXX","* DIGITE UNA CADENA :", "" ) );
int x = contPalabras( s ); //CONTAR LA CANTIDAD DE PALABRAS QUE TENGAN LA L
ETRA 'A'
EditMostrar->Text = EditMostrar->Text + ( x );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*if(esta("holopoto"))
ShowMessage("está");
else // SE ENCUANTRA LA LETRA 'A' EN LA CADENA
ShowMessage("No Está");*/ //OK
//------------------------------------------------------------------------------
/*String s=EditMostrar->Text;
s = ( InputBox("CADENAXXX","* DIGITE UNA CADENA :", "" ) );
elimVocales( s ); //ELIMINAR LAS VOCALES DE UNA CADENA
EditMostrar->Text = EditMostrar->Text+( s );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
///**************************************************************************///
///******************************* NATURALES ******************************///
///**************************************************************************///
//------------------------------------------------------------------------------
/*byte n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ",
"0" ) );
Mostrar( n );*/ // 1) MOSTRAR N PRIMEROS NATURALES OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*byte n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ",
"0" ) );
Mostrar1( n );*/ // 2) MOSTRAR N PRIMEROS NATURALES INVERSOS OK OK OK OK OK
OK
//------------------------------------------------------------------------------
/*byte n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ",
"0" ) );
MostrarPares( n );*/ // 3) MOSTRAR N PRIMEROS NUMEROS PARES OK OK OK OK OK O
K
//------------------------------------------------------------------------------
/*Cardinal x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO:
", "0" ) );
EliminarPares( x ); // 4) ELIMINA LOS DIGITOS PARES DE UN NRO OK OK OK OK OK
OK
ShowMessage( x );*/
//------------------------------------------------------------------------------
/*Cardinal x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO:
", "0" ) );
ShowMessage( SumaDigitosPares( x ) );*/ // 5) MOSTRAR SUMA DE DIGITOS PARES D
E UN NRO OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*Cardinal x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO:
", "0" ) );
ShowMessage( CantidadPar( x ) );*/ // 6) MOSTRAR CANTIDAD DE DIGITOS PARES DE
UN NRO OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*byte n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ",
"0" ) );
MostrarImpares( n );*/ // 7) MOSTRAR N PRIMEROS NUMEROS IMPARES OK OK OK OK
OK OK
//------------------------------------------------------------------------------
/*Cardinal n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO:
", "0" ) );
ShowMessage( SumaDigitos( n ) );*/ // 11) MOSTRAR SUMA DE LOS DIGITOS OK OK
OK OK OK OK
//------------------------------------------------------------------------------
/*Cardinal x, p, i;
x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ", "0" ) )
;
Sep_Imp_Par( p, i, x ); // 12) SEPARA LOS DIGITOS PARES E IMPARES DE UN NRO
OK OK OK OK OK OK
ShowMessage( " [ " +IntToStr( p ) +'|'+ IntToStr( i ) + " ] " );*/
//------------------------------------------------------------------------------
/*Cardinal x,y,z; malllllllllllllllllllllllllllllllllllllllllllllllllllllll
x = 3745;
y = 1234;
SepararParImpar( z, x, y ); // 8) SEPARA LOS DIGITOS PARES E IMPARES DE DOS N
RO
ShowMessage( " [ " +IntToStr( x ) +'|'+ IntToStr( y ) + " ] " ); */
//------------------------------------------------------------------------------
/*Cardinal x, y, z;
x = StrToInt(InputBox("** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ", "0" ) );
y = StrToInt(InputBox("** NÚMEROS NATURALES **", "* DIGITE OTRO NÚMERO: ", "0" ) )
;
juntar( x, y, z ); // 15) JUNTAR LOS DIGITOS DE 2 NÚMEROS EN UNO SOLO OK OK OK
OK OK OK
ShowMessage( z );*/
//------------------------------------------------------------------------------
/*Cardinal z; //malllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
ll
z = 98713;
Ordenar( z ); // 16) ORDENAR DIGITOS DE UN NRO
ShowMessage( z );*/
//------------------------------------------------------------------------------
/*Cardinal x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO:
", "0" ) );
ShowMessage( MenorDigito( x ) );*/ // 17) MOSTRAR EL MENOR DIGITO DE UN NRO
//8451962 MAAAAAAAAAAAAAAAAALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
//---------------------------------------------------------------------------
/*Cardinal x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO:
", "0" ) );
x = Fibo( x ); // 20)MUESTRA EL N-ÉSIMO TÉRMINO DE LA SERIE FIBONACCI OK OK OK OK
OK OK
ShowMessage( x );*/
//------------------------------------------------------------------------------
/*float p, x, n;
x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ", "0" ) )
;
n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE POTENCIA: ", "0" )
);
p = Potencia( x, n ); // 21)ELEVA UN NRO X A LA N OK OK OK OK OK OK
ShowMessage( p );*/
//------------------------------------------------------------------------------
/*Cardinal x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO:
", "0" ) );
if ( EsPar( x ) ) // 22) PROGRAMA QUE DEVUELVE TRUE SI UN NÚMERO ES PAR OK OK O
K OK OK OK
ShowMessage( "ES PAR" );
else
ShowMessage( "NO ES PAR" );*/
//------------------------------------------------------------------------------
/*Word x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ",
"0" ) );
MostrarHola( x );*/ // 23) MOSTRAR N VECES HOLA Y UN CHAU OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*byte n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ",
"0" ) );
ShowMessage( Factorial( n ) );*/ // 24) MUESTRA EL FACTORIAL DE UN NÚMERO OK OK
OK OK OK OK
//------------------------------------------------------------------------------
/*byte n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ",
"0" ) );
ShowMessage( Nesimo( n ) );*/ // 25) MUESTRA EL N-ÉSIMO TÉRMINO DE UNA SERIE OK OK
OK OK OK OK
//------------------------------------------------------------------------------
/*byte n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ",
"0" ) );
ShowMessage( GenerarSerie( n ) );*/ // 26) MUESTRA EL N-ÉSIMO TÉRMINO DE UNA SERI
E OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*byte n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ",
"0" ) );
ShowMessage( SumaSerie( n ) );*/ // 27) MUESTRA LA SUMA DE UNA SERIE OK OK OK
OK OK OK
//------------------------------------------------------------------------------
/*Cardinal x = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO:
", "0" ) );
ShowMessage( SepararDigito( x ) );*/ // 28) PROGRAMA QUE SEPARA LOS DÍGITOS DE
UN NÚMERO OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*int n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ", "
0" ) );
ShowMessage( SumaN( n ) );*/ // 29) PROGRAMA QUE SEPARA LA SUMA DE UNA SERIE
OK OK OK OK OK OK
/*int n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ", "
0" ) );
ShowMessage( Pro1( n ) );*/ // ) Pro1 OK OK OK OK OK OK
/*int n = StrToInt( InputBox( "** NÚMEROS NATURALES **", "* DIGITE UN NÚMERO: ", "
0" ) );
ShowMessage( Pro2( n ) );*/ // ) Pro2 OK OK OK OK OK OK
/*int v[ 50 ], i;
int n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* INGRESE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
} // ) Pro3 //
EditMostrar->Text = IntToStr( Pro3( v, n ) );*/ // OJO: INFINITOOOOOOOOOOOOOO
OO
/*int v[ 50 ], i;
int n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* INGRESE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
} // ) Pro4 //
EditMostrar->Text = IntToStr( Pro4( v, n ) );*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
///**************************************************************************///
///******************************* VECTORES *******************************///
///**************************************************************************///
//------------------------------------------------------------------------------
/*int x,v[7]={2,5,6,8,6,1,10};
byte z = 7;
x = SumaV( v, z ); // 13)MUESTRA LA SUMA DE LOS ELEMENTOS DE UN VECTOR //
ShowMessage( x );*/ //OK
//------------------------------------------------------------------------------
/*int x,v[7]={3,5,6,8,6,1,1};
byte z = 7;
x = SumaImpares( v, 7 ); // 14)MUESTRA LA SUMA DE LOS ELEMENTOS IMPARES DE UN
VECTOR //
ShowMessage( x );*/ //OK
//------------------------------------------------------------------------------
/*int x,v[7]={3,7,14,5,2,16,15};
Word n = 7;
x = sumParImp( v, n ); // X)MUESTRA LA SUMA DE LOS ELEMENTOS PARES CON IMPARE
S DE UN VECTOR //
ShowMessage( x );*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*int v[7]={3,7,14,5,2,16,15};
short n = 7;
int v1[8]={1,2,3,4,5,6,7,9};
short m = 8;
intercambiar( v, v1, n, m );
ShowMessage( "[" + VecToStr( v, n) + "]" );
ShowMessage( "[" + VecToStr( v1,m) + "]" );*/
/*int v[5]={1,2,3,4,5};
int n = 5;
float x;
x = promedio( v, n ); // 15)MUESTRA EL PROMEDIO DE LOS ELEMENTOS DE UN VECTOR
//
ShowMessage( x );*/
/*int v[ 50 ], i;
int n, x;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( " EJERCICIO DE VERANO ", "* INGRESE DIMENSIÓN: ", "0" )
);
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( " EJERCICIO DE VERANO ", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
} // ) PROMEDIO DE LOS DÍGITOS DE UN VECTOR //
x = promedio( v, n );
EditMostrar->Text = IntToStr( x );*/ // OK OK OK OK OK OK
/*int v[4]={3,7,14,5};
int n = 4;
int v1[4]={1,2,8,4};
int m = 4;
int vx[ 50 ] = { 50 };
int k = 50;
concatenar( v, v1, n, m, vx, k );
ShowMessage( "[" + VecToStr2( v, v1, n, m ) + "]" );*/ // OK OK OK OK OK OK
/*int v[4]={3,7,14,5};
int n = 4;
int v1[3]={1,2,8};
int m = 4;
int vx[ 50 ] = { 50 };
int k = 50;
prodCartesiano( v, v1, n, m, vx );
//concatenar( v, v1, n, m, vx, k );
ShowMessage( "[" + VecToStr2( v, v1, n, m ) + "]" );*/
/*int x, v[ 6 ] = { 1, 2, 3, 4, 5, 5 };
short n = 6;
if ( repetidos( v, n ) ) // 24)BUSQUEDA BINARIA //
ShowMessage( "SI HAY DOS NÚMEROS REPETIDOS =)" );
else // OK
ShowMessage( "NO HAY DOS NÚMEORS REPETIDOS =(" );*/
/*int v[7]={3,7,9,5,2,10,8};
int n = 7;
int x;
x = prodMaxMin( v, n );
ShowMessage( x );*/ //OK OK OK OK OK OK
/*int v[ 50 ], i;
int n,x;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* INGRESE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
} // ) PRODUCTO DEL VALOR MAXIMO POR EL MINIMO //
x = prodMaxMin( v, n );
EditMostrar->Text = IntToStr( x );*/ // OK OK OK OK OK OK
/*int v[ 3 ] = { 1, 1, 1 };
int n = 3;
int v1[ 3 ] = { 0, 1, 0 };
int m = 3;
int x;
x = hamming( v, v1, n, m ); // OK OK OK OK OK OK
ShowMessage( x );*/
//------------------------------------------------------------------------------
/*int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* INGRESE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
} // 32)MUESTRA LA SUMA DE LOS ELEMENTOS PARES DE UN VECTOR //
EditMostrar->Text = IntToStr( sumaPares( v, n ) );*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*int v[7]={2,6,8,16,7,1,1};
int z = 7;
float x;
x = PromedioV( v, z ); // 15)MUESTRA EL PROMEDIO DE LOS ELEMENTOS DE UN VECTO
R //
ShowMessage( x );*/ //OK
//------------------------------------------------------------------------------
/*int v[7]={3,7,4,5,1,13,2};
Rotar(v,7); // 16)ROTAR UNA CASILLA A LA DERECHA ELEMENTOS DEL VECTOR //
ShowMessage( "[" + VecToStr( v, 7 ) + "]" );*/ //OK OK OK OK OK OK
//rotarDer( Vextor, Vextor->ColCount ); // OK OK OK OK OK OK
// rotarIzq1( Vextor, Vextor->ColCount ); // OK OK OK OK OK OK
/*int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* INGRESE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
//Rotar( v, n ); // 16)ROTAR UNA CASILLA A LA DERECHA ELEMENTOS DEL VECTOR //
rotarIzq( v, n );// xxxxx)ROTAR UNA CASILLA A LA IZQUIERDA ELEMENTOS DEL VECTO
R //
EditMostrar->Text = ( "[" + VecToStr( v, n ) + "]" );*/ //OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*int v[ 7 ] = { 1, 3, 5, 8, 9, 10, 6 };
InsertarX(v,7); // 16.1)INSERTAR UN ELEMENTO A S
U LUGAR //
ShowMessage( "[" + VecToStr( v, 7 ) + "]" );*/ //OK
//------------------------------------------------------------------------------
/*int x,v[10]={2,8,-5,10,15,4,6,9,2,7};
short int n = 1;
x = Mayor( v, 4 ); // 17)MUESTRA EL MAYOR DE LOS ELEMENTOS DE UN VECTOR //
ShowMessage( x );*/
//------------------------------------------------------------------------------
/*int v[ 7 ] = { 5, 7, 1, 4, 6, 3, 2 };
InsertionSort(v,7); // 17.1)ORDENAR LOS ELEMENTOS DEL VECTOR POR BARAJA //
ShowMessage( VecToStr( v, 7 ) );*/ //OJO SALE STACK OVERFLOW
//------------------------------------------------------------------------------
/*int x,v[6]={7,3,1,5,3,2};
int n = 6;
EliminarElemento( v, n, 3 ); // 18)ELIMINA UN ELEMENTO DEL
VECTOR //
ShowMessage( "[" + VecToStr( v, n )+ "]" );*/ //OK OK OK OK OK OK
/*int v[ 50 ], i;
int n, x;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* DIGITE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
x = StrToInt( InputBox( "VEXXXTOR", "* DIGITE NÚMERO A ELIMINAR: ", "0" ) );
EliminarElemento( v, n, x ); // eliminar dato //
for ( i = 0; i < n; i++ ) {
EditMostrar->Text = EditMostrar->Text +","+IntToStr( v[ i ] );
}*/ // OK OK OK OK OK OK
/*int x;
x = StrToInt( InputBox( "VEXXXTOR", "* DIGITE NÚMERO A ELIMINAR: ", "0" ) );
elimDato( Vextor, Vextor->ColCount, x );*/ //MALLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
//------------------------------------------------------------------------------
/*int v[7]={7,4,1,8,5,3,6};
Burbu( v, 7 ); // 19)LLEVA EL MAYOR DIGITO A LA ÚLTIMA CASILLA DEL VECTOR //
ShowMessage( VecToStr( v, 7 ) );*/ //OK OK OK OK OK OK
//burbujita( Vextor, Vextor->ColCount ); //mallllllllllllllllllllllllllll
//------------------------------------------------------------------------------
/*bool v[6]={7,1,5,8,6,4};
Ordenar( v, 6 ) // 20)VERIFICA SI LOS ELEMENTOS DEL VECTOR ESTÁ ORDENADO//
ShowMessage( VecToStr( v, 6 ) ); */
//------------------------------------------------------------------------------
/*int v[6]={1,3,8,9,10,7};
short n = 6;
Invertir( v, n ); // 23)INVERTIR LOS ELEMENTOS DE
UN VECTOR //
ShowMessage( "[" + VecToStr( v, n ) + "]" );*/ //OK
//------------------------------------------------------------------------------
/*int x, v[ 12 ] = {1, 2, 4, 6, 9, 10, 11, 12, 20, 30, 31, 35 };
short n = 12;
if ( BusBin( v, n, 10 ) ) // 24)BUSQUEDA BINARIA //
ShowMessage( "SE ENCUENTRA EL VALOR =)" );
else // OK
ShowMessage( "NO SE ENCUENTRA EL VALOR =(" );*/
//------------------------------------------------------------------------------
/*int v[ 8 ] = {4, 1, 5, 8, 6, 3, 2, 9 };
Word n = 8;
if ( EstaAntes( v, n, 3, 5 ) ) // 26)ESTÁ ANTES X DE Y EN UN VEC
TOR //
ShowMessage( "SE ENCUENTRA ANTES =)" );
else // OK
ShowMessage( "NO SE ENCUENTRA ANTES =(" );*/
//------------------------------------------------------------------------------
/*int x, v[ 12 ] = {1, 2, 4, 6, 9, 10, 11, 12, 20, 30, 31, 35 };
Cardinal n = 12;
if ( EstaOrdenado( v, n ) ) // 9.1)ESTA ORDENADO EL VECTOR DE
MENOR A MAYOR //
ShowMessage( "SE ENCUENTRA ORDENADO =)" );
else // OK
ShowMessage( "NO SE ENCUENTRA ORDENADO =(" ); */
//------------------------------------------------------------------------------
/*int x, v[ 7 ] = { 7,5,4,15,2,2,0, };
Cardinal n = 7;
if ( EstaOrdenado1( v, n ) ) // 9.2)ESTA ORDENADO EL VECTOR D
E MAYOR A MENOR //
ShowMessage( "SE ENCUENTRA ORDENADO =)" );
else // OK
ShowMessage( "NO SE ENCUENTRA ORDENADO =(" );*/
//------------------------------------------------------------------------------
/*int v[ 5 ] = { 9, 8, 10, 2, 3 };
Word n = 5;
P(v,n);
ShowMessage( "[" + VecToStr( v, n ) + "]" );*/ //OK
//------------------------------------------------------------------------------
/*int v[ 8 ] = { 8 };
Word n = 8;
CargarFibo(v,n);
ShowMessage( "[" + VecToStr( v, n ) + "]" );*/ //OK
//------------------------------------------------------------------------------
/*int v[7]={3,7,1,4,2,9,5};
int x=7;
ShowMessage(sumaPosPares(v,x));*/ // maaaaaaaaaaaaaalllllllllllllllllllllllll
//------------------------------------------------------------------------------
/*int v[ 7 ] = { 7,5,4,15,2,2,0, };
int n = 3;
int m = 1;
if ( EstaOrdenadovector( v, n, m ) ) // 9.2)ESTA ORDENADO EL VECTOR DE MAYOR
A MENOR //
ShowMessage( "ESTÁ ORDENADO " + IntToStr( m ) );
else // OK OJOOOOOOOOOOO
ShowMessage( "NO ESTÁ ORDENADO " + IntToStr( m ) );*/
//------------------------------------------------------------------------------
/*int v[6]={1,3,8,9,10,7};
int n = 6; //ojoooooooooooooooooooooooooooooooooooooooo
o
int Max,Min;
MaxMin(v,n,Max,Min); // 23)MAX & MIN ELEMENTO DE UN VECTOR
//
ShowMessage( "[" + VecToStr( v, n ) + "]" );*/ //OK
//------------------------------------------------------------------------------
/*int a,b;
int n = V1.GetDimension();
V1.MaxMin(n,a,b); //ojoooo este es el ejemplo de llamada
Edit2->Text = StrToInt(a);
Edit3->Text = StrToInt(b);*/
//------------------------------------------------------------------------------
/*int v[ 10 ] = { 0, 9, 3, 6, 7, 4, 5, 1, 13, 2 };
sepParImp( v, 10 ); // )SEPARAR LOS DIGITOS PARES E IMPARES DEL VECTOR //
ShowMessage( "[" + VecToStr( v, 10 ) + "]" );*/ //OK OK OK OK OK OK
/*int v[ 50 ], i;
Word n;
Edit1->Clear( );
EditMostrar->Clear( );
Edit2->Clear( );
n = StrToInt( InputBox( "VEXXXTOR", "* DIGITE DIMENSIÓN: ", "0" ) );
for ( i = 0; i < n; i++ ) {
v[ i ] = StrToInt( InputBox( "VEXXXTOR", "* VALOR: ", "0" ) );
Edit1->Text = Edit1->Text + "-" + IntToStr( v[ i ] );
}
sepParImp( v, n ); // )SEPARAR LOS DIGITOS PARES E IMPARES DEL VECTOR //
for ( i = 0; i < n; i++ ) {
EditMostrar->Text = EditMostrar->Text +","+IntToStr( v[ i ] );
}*/ // OK OK OK OK OK OK
//------------------------------------------------------------------------------
/*int x, v[ 11 ] = { 3,7,1,4,2,9,5, 9,8,7,6};
int z = 7;
x = sumaPosPares( v, z ); // )MUESTRA LA SUMA DE LAS POSICIONES PARES DE ELEME
NTOS DE UN VECTOR //
ShowMessage( x );*/ //OK OK OK OK OK OK
}
//------------------------------------------------------------------------------
///**************************************************************************///
///******************************* MATRICES *******************************///
///**************************************************************************///
//------------------------------------------------------------------------------
void __fastcall TForm1::BTNCARGAMATRICESClick( TObject *Sender ) {
/*int m = StrToInt( InputBox( "MATRIXXX", "* DIGITE NRO DE FILAS: ", "0" ) );
int n = StrToInt( InputBox( "MATRIXXX", "* DIGITE NRO DE COLUMNAS: ", "0" ) );
Matrix->ColCount = n;
Matrix->RowCount = m;
magicVer( Matrix, m, m, 0, m / 2, 1 );*/ // OK OK OK OK OK OK DE VERANO # 22
//---------------------------------------------------------------------------
void __fastcall TForm1::magico1Click(TObject *Sender) {
short m, n;
m = StrToInt( InputBox( "MATRIXXX", "* DIGITE DIMENSIÓN: ", "0" ) );
Matrix->ColCount = m;
Matrix->RowCount = m;
Magico( Matrix, m, m, 0, m / 2, 1 ); //OK OK OK OK OK OK
}
//---------------------------------------------------------------------------
void __fastcall TForm1::llenarAlRevesClick(TObject *Sender) {
int m = StrToInt( InputBox( "MATRIXXX", "* DIGITE NRO DE FILAS: ", "0" ) );
int n = StrToInt( InputBox( "MATRIXXX", "* DIGITE NRO DE COLUMNAS: ", "0" ) );
int f = m-1;
int c = n-1;
Matrix->ColCount = n;
Matrix->RowCount = m;
llenarReves( Matrix, m, n, f, c ); //OK OK OK OK OK OK
}
//---------------------------------------------------------------------------
void __fastcall TForm1::llenar1Click(TObject *Sender) {
int m = StrToInt( InputBox( "MATRIXXX", "* DIGITE NRO DE FILAS: ", "0" ) );
int n = StrToInt( InputBox( "MATRIXXX", "* DIGITE NRO DE COLUMNAS: ", "0" ) );
Matrix->ColCount = n;
Matrix->RowCount = m;
LlenarMatriz1( Matrix, m, n ); //OK OK OK OK OK OK
}
//---------------------------------------------------------------------------
void __fastcall TForm1::magicox2Click(TObject *Sender) {
int m = StrToInt( InputBox( "MATRIXXX", "* DIGITE DIMENSIÓN: ", "0" ) );
int f = m - 1;
int c = m / 2;
Matrix->ColCount = m;
Matrix->RowCount = m;
magico2( Matrix, m, f, c, m * m ); //OK OK OK OK OK OK
}
//---------------------------------------------------------------------------
void __fastcall TForm1::matrizAuxClick(TObject *Sender) {
int m = StrToInt( InputBox( "MATRIXXX", "* DIGITE DIMENSIÓN: ", "0" ) );
int f = 0;
int c = m - 1;
int dato = limiteM( m );
matriztri( Matrix, m, f, c, dato ); //OK OK OK OK OK OK
}
//---------------------------------------------------------------------------
void __fastcall TForm1::matrizElementalClick(TObject *Sender) {
int m = StrToInt( InputBox( "MATRIXXX", "* DIGITE DIMENSIÓN: ", "0" ) );
int f = m - 1;
int c = m - 1;
espiral( Matrix , m , f , c , m*m ); //OK OK OK OK OK OK
}
//---------------------------------------------------------------------------
void __fastcall TForm1::estaOrdenMatrizClick(TObject *Sender) {
/*int m = StrToInt( InputBox( "MATRIXXX", "* DIGITE NRO DE FILAS: ", "0" ) );
int n = StrToInt( InputBox( "MATRIXXX", "* DIGITE NRO DE COLUMNAS: ", "0" ) );
Matrix->ColCount = n;
Matrix->RowCount = m;
LlenarMatriz1( Matrix, m, n );*/
/*int f = m;
int c = n;
if ( estaOrdenada( Matrix , m , n , f ,c ) )
ShowMessage ("true");
else
ShowMessage ("false");*/
}
//---------------------------------------------------------------------------