Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- //La biblioteca manipulara los numeros mediantes arreglo
- //Cada elemento del arreglo se guardara una cifra del numero
- //Todos los arreglos que manipularan los numeros seran del tipo entero char
- //Y las cifras se guardaran como numero mas no como caracter
- #include <cstdlib>
- #include <stdio.h>
- #include <iostream>
- #include <iomanip>
- using namespace std;
- #define MAX 30
- int lee(int base, char numG[]) {
- int i = MAX;
- char c;
- bool positivo = true;
- while (1) {
- c = cin.get();
- if (c == '-') {
- positivo = false;
- break;
- } else if (c == EOF) return EOF;
- else if (((c - '0') < base) && ((c - '0') >= 0)) {
- numG[i] = c - '0';
- i--;
- break;
- } else if (((c - '0') >= base) && ((c - '0') < 10)) // Alguna Cifra no corresponde a la base
- return 0;
- }
- while (1) {
- c = cin.get();
- if ((c - '0') >= base && (c - '0') < 10) {
- return 0;
- } else if ((c - '0') < base && (c - '0') >= 0) {
- numG[i] = c - '0';
- i--;
- } else
- break;
- }
- if (i < 0)
- return 2;
- if (positivo)
- numG[i] = '+';
- else
- numG[i] = '-';
- return 1;
- }
- int suma(int base, char numG1[], char numG2[], char resp[]);
- int resta(int base, char numG1[], char numG2[], char resp[]);
- int multCifra(int base, char numG1[], char cifra, char resp[]);
- int multiplica(int base, char numG1[], char numG2[], char resp[]);
- int imprime(char numG1[]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement