Yuan Moderador
Cantidad de envíos : 8 Edad : 34 Fecha de inscripción : 17/10/2008
| Tema: Verificar si un numero es PALINDROME !!! Vie 12 Dic 2008, 19:22 | |
| Buenas buenas ... les tengo un regalito ... este programilla te dice si el numero que ingresas es PALINDROME ... :O Suerte cabros... - Código:
-
#include<stdio.h> #include<conio.h> #include<stdlib.h>
void insertar(); void imprimir(); void verificar(); void copiar();
typedef struct nodo_1 { int digito; struct nodo_1 *sgte; }nodo_1;
int dato_1; nodo_1 *act_1,*inicio_1=NULL;
typedef struct nodo_aux { int digito_2; struct nodo_aux *sgte; }nodo_aux;
int dato_2; nodo_aux *act_2,*inicio_2=NULL;
int temp; int cont; main() { int opcion; do { system("cls"); printf("\n\n *** MENU ***\n"); printf("\n Opcion 1: Ingresar digitos"); printf("\n Opcion 2: Imprimir digitos"); printf("\n Opcion 3: Verificar si es PALINDROME"); printf("\n Opcion 4: Salir del Programa");
printf("\n\n Ingresar una opcion: "); scanf("%d",&opcion); printf("\n"); switch(opcion) { case 1: insertar(); break; case 2: imprimir(); break; case 3: verificar(); break; case 4: exit(0); default: printf("\n OPCION NO EXISTE !!!"); getch(); } } while(opcion!=4); }
void insertar() { fflush(stdin); printf("\n Ingrese un digito: "); scanf("%d",&dato_1); act_1=(nodo_1*)malloc(sizeof(nodo_1)); act_1->digito=dato_1; act_1->sgte=inicio_1; inicio_1=act_1; }
void imprimir() { act_1=inicio_1; while(act_1!=NULL) { printf(" %d ",act_1->digito); act_1=act_1->sgte; } printf("\n\n ** PRESIONE CUALQUIER TECLA PARA VOLVER AL MENU **"); getch(); }
void verificar() { act_1=inicio_1; while(act_1!=NULL) { temp=act_1->digito; act_2=(nodo_aux*)malloc(sizeof(nodo_aux)); act_2->digito_2=temp; act_2->sgte=inicio_2; inicio_2=act_2; act_1=act_1->sgte; } act_1=inicio_1; act_2=inicio_2; while(act_1!=NULL && act_2!=NULL ) { if(act_1->digito==act_2->digito_2) cont=1; else { cont=0; } act_1=act_1->sgte; act_2=act_2->sgte; } if(cont==1) { printf("\n EL NUMERO ES PALINDROME"); getch(); } else printf("\n EL NUMERO NO ES PALINDROME"); getch(); }
| |
|