Skip to content

Instantly share code, notes, and snippets.

@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 / 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;