Created
October 15, 2013 00:48
-
-
Save anonymous/6984848 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ===================================================================================== | |
* | |
* Filename: c.cpp | |
* | |
* Description: Our attempt at the 'Give me an E' problem | |
* | |
* Version: 1.0 | |
* Created: 10/14/2013 06:14:39 PM | |
* Revision: none | |
* Compiler: gcc | |
* | |
* Author: Eli Gundry | |
* Brian Boll | |
* Johnny Beedlow | |
* | |
* ===================================================================================== | |
*/ | |
#include <string> | |
#include <iostream> | |
#include <vector> | |
#include <stdio.h> | |
#include <sstream> | |
const int MAX_SIZE = 10; | |
void generateNonEs(std::vector<int>& list) | |
{ | |
std::ostringstream stream1; | |
std::string temp_i; | |
int i = 1, | |
place_counter = 0; | |
do { | |
// Convert int to string | |
stream1.str(""); | |
stream1.clear(); | |
stream1 << i; | |
temp_i = stream1.str(); | |
place_counter = 0; | |
bool found_e = false; | |
for (std::string::iterator it = temp_i.end(); it != temp_i.begin() || !found_e; --it, ++place_counter) { | |
if ((place_counter % 4) == 0) { | |
if ((*it != '2') && (*it != '4') && (*it != '6')) { | |
found_e = true; | |
} | |
} | |
if ((place_counter % 4) == 1) { | |
if ((*it != '3') && (*it != '4') && (*it != '5') && (*it != '6')) { | |
found_e = true; | |
} | |
} | |
if ((place_counter % 4) == 2) { | |
if (*it != '0') { | |
found_e = true; | |
} | |
} | |
if (it == temp_i.begin()) { | |
std::cout << *it << std::endl; | |
list.push_back(i); | |
} | |
} | |
++i; | |
} while (list.size() < MAX_SIZE); | |
} | |
int main() | |
{ | |
char temp[100]; | |
int input; | |
std::vector<int> list_of_non_e; | |
generateNonEs(list_of_non_e); | |
for (int i = 0; i < MAX_SIZE; ++i) | |
std::cout << i << ": " << list_of_non_e[i] << std::endl; | |
// while (std::cin.getline(temp, 100)) { | |
// sscanf(temp, "%d", input); | |
// std::cout << input << std::endl; | |
// // results.push_back(list_of_non_e[input]); | |
// } | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment