Hola

Dependencies:   mbed

main.cpp

Committer:
elchef
Date:
2014-04-10
Revision:
0:fbe6e5bf1b70

File content as of revision 0:fbe6e5bf1b70:

//Juan Carlos Verduzco Gastélum A01112580
//Gabriel Ivan López Aviña A01223680
#include "mbed.h"
#define SIZE 10
Serial pc(USBTX, USBRX);

int valid_ISBN (int *arreglo, int tamaño){
    int suma = 0;
    if (arreglo[9] == 'X' || arreglo[9] == 'x'){
        arreglo[9] = 10;   
    }    
    for (int index=0; index < tamaño; index = index +1){
        int producto = arreglo[index]*(index+1);
        suma += producto;
        pc.printf("La suma es: %i", suma);
    }
    
    if(suma%11 == 0){
    return 1;
    }
    return 0;
}


int main(){
    int ISBN[SIZE]={1,6,0,4,5,9,8,9,3,'X'};  
    // Art of War: 160459893X
    bool prueba;
    
    prueba = valid_ISBN(ISBN, SIZE);
    if (prueba == 1){
        pc.printf("El ISBN es válido");    
    } else {
        pc.printf("El ISBN es falso");    
    }
    return 0;