Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- #include <stdio.h>
- #include <string.h>
- size_t hexa_to_decimal(char c) {
- if (c >= '0' && c <= '9')
- return (size_t)(c-'0');
- else
- return (size_t)(c-'A' + 10);
- }
- std::istream& operator >> (std::istream& i, std::list<std::string>& l) {
- std::cout << "Ingrese el numero de elementos a cargar en formato hexa: ";
- char aux[100];
- i >> aux;
- size_t len_aux = strlen(aux);
- size_t mult = 1;
- size_t cantidad = 0;
- for (size_t j = 0; j < len_aux; ++j) {
- cantidad += hexa_to_decimal(aux[j]) * mult;
- mult *= 16;
- }
- for (size_t j = 0; j < cantidad; ++j) {
- i >> aux;
- std::string aux_string(aux);
- l.push_back(aux_string);
- }
- return i;
- }
- int main() {
- std::list<std::string> l;
- std::cin >> l;
- std::list<std::string>::iterator it = l.begin();
- while (it != l.end()) {
- std::cout << *it << std::endl;
- ++it;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement