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
/* Creates a diamond */ | |
/* Needed for standard IO features */ | |
#include <stdio.h> | |
int main() | |
{ | |
/* The number of lines we want the diamond to be */ | |
int lines, x, y; | |
int stars = 1; |
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
/* Creates a triangle */ | |
#include <stdio.h> | |
int main() | |
{ | |
/* vars */ | |
int lines, stars, x, y; | |
printf("How many lines do you wish the triangle to be?: "); |
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
/* http://rosettacode.org/wiki/100_doors */ | |
#include <stdio.h> | |
int main() | |
{ | |
int x, y; | |
int doors[100] = { 0 }; | |
/* Loop the 100 times */ |
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
/* http://rosettacode.org/wiki/99_Bottles_of_Beer */ | |
#include <stdio.h> | |
int main() | |
{ | |
int bottles; | |
for(bottles = 99; bottles > 0; --bottles) | |
{ |
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
/** Write a program that prompts the user for a positive integer | |
* and then reports the closest integer having a whole number square root. | |
* For example if the user enters 8 then the program reports 9. | |
* The program should work for any number having one to seven digits. | |
*/ | |
#include <stdio.h> | |
/* Checks to see if the number is a perfect square. | |
returns 1 for yes, 0 for no. */ |
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
/** Write a program that prompts the user for a positive | |
* integer and then computes the sum of all the digits of | |
* the number. For example, if the user enters 2784, | |
* then the program reports 21. If the user enters 59, | |
* then the program reports 14. The program should work | |
* for any number having one to ten digits. | |
*/ | |
#include <iostream> | |
#include <string> |
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
#include <iostream> | |
#include <cmath> | |
#include "Prime.h" | |
int main() | |
{ | |
int x; | |
bool Failure = false; | |
for (x = 1; Failure != true; ++x) |
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
# Enter the encoded password from HackThisSite | |
encoded_password = "a9;96j6i" | |
# empty string for the decoded password | |
password = "" | |
# Loop for the length of the encoded password | |
0.upto(encoded_password.length-1) do |x| | |
password += ((encoded_password[x].ord)-x).chr | |
end |
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
#include <iostream> // Needed for std::cout/cin | |
#include <vector> // Needed for std::vector | |
#include <string> // Needed for std::string | |
#include <algorithm> // Needed for std::sort | |
int main() | |
{ | |
std::string user_input; | |
std::vector<int> digits; | |
bool negative; |
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
#include <iostream> // Needed for std::cin/cout | |
#include <vector> // Needed for std::vector | |
#include <cmath> // Needed for sqrt and ceil | |
int main() | |
{ | |
/* Will be the sieve */ | |
std::vector<bool> Sieve; | |
unsigned int x, y, limit; |
OlderNewer