- Código: Seleccionar todo
// palindroom.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#define MAX 40
int lees(int tabel[])
{
int i=1,get,res=1;
printf ("Geef reeks getalen:");
scanf ("%d", &get);
while (get>=0 && i<MAX)
{
tabel[i]=get;
i++;
if (i<MAX)
scanf ("%d", &get);
}
return (i-1);
}
int palindroom( int tabel[], int eindgrens) //si se lee igual de adelante hacia atras y viceversa, debe regresar valor TRUE
{
int i=0, res=1,end=eindgrens/2;
while (i<=end && res)
{
if (tabel[i]!=tabel[eindgrens-1])
res=0;
i++;
}
return res;}
void main()
{
int tabel[MAX],eindgrens,p;
eindgrens=lees(tabel);
printf ("%d", eindgrens);
p=palindroom (tabel, eindgrens);
printf ("%d\n",p);
if (p!=0)
printf ("palindroom\n"); //verdadero
else
printf ("geen palindroom\n"); //falso
}
Gracias de antemano








