Skip to content

Instantly share code, notes, and snippets.

@swimmi
swimmi / Easier Done Than Said
Created April 22, 2014 09:42
Output each password is or not acceptable
#include <fstream>
#include <iostream>
using namespace std;
//Output each password is or not acceptable.
int main()
{
//ifstream cin("easier_done_than_said.txt");
string s;
int a,b; //count of consecutive vowels and consonants
bool c1,c2,c3,is; //fill rules 1-3 and consecutive or not
@swimmi
swimmi / File Searching
Created April 22, 2014 08:33
Searching files by queries !
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
//Searching files by queries !
int main()
{
//ifstream cin("file_searching.txt");
int n=0,m=0;
@swimmi
swimmi / Martian Addition
Created April 21, 2014 16:02
Calculate the sum of 2 numbers in Mars
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
//Calculate the sum of 2 numbers in Mars.
int main()
{
//ifstream cin("martian_addition.txt");
string a,b;
string s="0123456789abcdefghijk"; //more than 20 ! The key is 'k'.
@swimmi
swimmi / Error Correction
Created April 21, 2014 14:02
Check a matrix if it has the parity property
#include <fstream>
#include <iostream>
using namespace std;
//Check a matrix if it has the parity property.
int main()
{
//ifstream cin("error_correction.txt");
int n;
while(cin>>n)
{
@swimmi
swimmi / Daffodil Number
Created April 21, 2014 11:42
Is this a daffodil number?
#include <fstream>
#include <iostream>
using namespace std;
//Is this a daffodil number?
int main()
{
//ifstream cin("daffodil_number.txt");
int num;
while(cin>>num)
{
@swimmi
swimmi / DNA Sorting
Created April 21, 2014 11:22
Arrange from "most sorted" to "least sorted"
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
//Arrange from "most sorted" to "least sorted".
bool comp(const string &s1, const string &s2)
{
string s[]={s1,s2};
int c[]={0,0};
@swimmi
swimmi / Beautiful Meadow
Created April 21, 2014 06:02
Is Tom's meadow beautiful now?
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
//Is Tom's meadow beautiful now?
int main()
{
//ifstream cin("beautiful_meadow.txt");
int n,m;
@swimmi
swimmi / Image Transformation
Created April 20, 2014 17:38
Transform a RGB image into gray
#include <fstream>
#include <iostream>
using namespace std;
//Transform a RGB image into gray.
int main()
{
//ifstream cin("image_transformation.txt");
int x,y;
int index=1;
while(cin>>x>>y)
@swimmi
swimmi / Adding Reversed Numbers
Created April 20, 2014 16:51
Reverse two numbers and add then reverse the sum
#include <fstream>
#include <iostream>
#include <algorithm>
#include <sstream>
using namespace std;
//Reverse two numbers and add then reverse the sum.
int main()
{
//ifstream cin("adding_reversed_numbers.txt");
int n;
@swimmi
swimmi / A Simple Question of Chemistry
Created April 20, 2014 14:22
Calculate the difference between this temperature and the previous one
#include <fstream>
#include <iostream>
using namespace std;
//Calculate the difference between this temperature and the previous one.
int main()
{
//ifstream cin("a_simple_question_of_chemistry.txt");
double a,b;
cin>>a;
while(cin>>b)