This file contains 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
// konesinarow.cpp | |
// juanfc 2012-06-24 | |
// Design a program that reads from keyboard two natural numbers $k$ and | |
// $n$ and sends to the screen a message that indicates whether $n$ has | |
// got at least $k$ 1s (ones) straight without a break, or not. For example, | |
// if $k=3$ and $n=135$ the program should display ‘Yes’ since 135 as binary | |
// is ‘1000 0111’ that does have at least 3 ones in a row. | |
This file contains 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
// stringtest.cpp | |
// juanfc 2009-02-25 | |
// http://www.cplusplus.com/reference/string/string/ | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
int main(int argc, char *argv[]) | |
{ |
This file contains 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
// structsample.cpp | |
// juanfc 2011-12-08 | |
// | |
#include <iostream> | |
using namespace std; | |
// types | |
enum TMonth { JAN, FEB, MAR, APR, MAY, JUN, | |
JUL, AUG, SEP, OCT, NOV, DEC }; |
This file contains 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
// planetas.cpp | |
// juanfc 2012-06-24 | |
// | |
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
const float G = 6.6738410E-11; // N·m2/kg2 |
This file contains 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
bool isPrime(unsigned num) | |
{ | |
int i = 2; | |
while (i < num and num % i != 0) | |
++i; | |
return i >= num; | |
} |
This file contains 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
// mesdeunafecha.cpp | |
// juanfc 2012-06-24 | |
// | |
#include <iostream> | |
using namespace std; | |
string mesdeunafecha(string fecha); |
This file contains 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
// euler3.cpp | |
// juanfc 2012-06-24 | |
// The prime factors of 13195 are 5, 7, 13 and 29. | |
// What is the largest prime factor of the number 600851475143 ? | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ |
This file contains 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
#include <iostream> | |
using namespace std; | |
void binary (int a, int base = 10); | |
int main() | |
{ | |
int a, base; | |
cout << "Enter number and base:"; | |
cin >> a >> base; |
This file contains 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
// 004.palindromeLargest.cpp | |
// juanfc 2012-06-24 | |
// A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. | |
// Find the largest palindrome made from the product of two 3-digit numbers. | |
#include <iostream> | |
using namespace std; | |
const int NOOFDIGITS = 3; |
This file contains 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
// 004.palindromeLargest.cpp | |
// juanfc 2012-06-24 | |
// A palindromic number reads the same both ways. The largest palindrome made | |
// from the product of two 2-digit numbers is 9009 = 91 x 99. | |
// Find the largest palindrome made from the product of two 3-digit numbers. | |
#include <iostream> | |
#include <sstream> | |
using namespace std; |