Advertisement
xlujiax

2013_2 Biblioteca Statica

Sep 14th, 2016
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. //La biblioteca manipulara los numeros mediantes arreglo
  8. //Cada elemento del arreglo se guardara una cifra del numero
  9. //Todos los arreglos que manipularan los numeros seran del tipo entero char
  10. //Y las cifras se guardaran como numero mas no como caracter
  11.  
  12. #include <cstdlib>
  13. #include <stdio.h>
  14. #include <iostream>
  15. #include <iomanip>
  16.  
  17. using namespace std;
  18.  
  19. #define MAX 30
  20.  
  21. int lee(int base, char numG[]) {
  22.     int i = MAX;
  23.     char c;
  24.     bool positivo = true;
  25.     while (1) {
  26.         c = cin.get();
  27.         if (c == '-') {
  28.             positivo = false;
  29.             break;
  30.         } else if (c == EOF) return EOF;
  31.  
  32.         else if (((c - '0') < base) && ((c - '0') >= 0)) {
  33.             numG[i] = c - '0';
  34.             i--;
  35.             break;
  36.         } else if (((c - '0') >= base) && ((c - '0') < 10)) // Alguna Cifra no corresponde a la base
  37.             return 0;
  38.     }
  39.     while (1) {
  40.         c = cin.get();
  41.         if ((c - '0') >= base && (c - '0') < 10) {
  42.             return 0;
  43.         } else if ((c - '0') < base && (c - '0') >= 0) {
  44.             numG[i] = c - '0';
  45.             i--;
  46.         } else
  47.             break;
  48.     }
  49.     if (i < 0)
  50.         return 2;
  51.     if (positivo)
  52.         numG[i] = '+';
  53.     else
  54.         numG[i] = '-';
  55.     return 1;
  56. }
  57.  
  58. int suma(int base, char numG1[], char numG2[], char resp[]);
  59.  
  60. int resta(int base, char numG1[], char numG2[], char resp[]);
  61.  
  62. int multCifra(int base, char numG1[], char cifra, char resp[]);
  63.  
  64. int multiplica(int base, char numG1[], char numG2[], char resp[]);
  65.  
  66. int imprime(char numG1[]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement