Skip to content

Instantly share code, notes, and snippets.

View gallirohik's full-sized avatar

Rohik Galli gallirohik

View GitHub Profile
@gallirohik
gallirohik / decimal_to_any.c
Created March 5, 2018 18:22
conver decimal to any number system
#include <stdio.h>
#include <stdlib.h>
char value(int val)
{
if(val>=0&&val<=9)
return val+'0';
return val-10+'A';
}
void convert_to(int n,int base,char *p)
{
@gallirohik
gallirohik / count_pair.c
Created March 5, 2018 19:09
finding the pair in the given string(two letters are said to be pair,if they are eqal and have a charecter in between them).
#include <stdio.h>
#include <stdlib.h>
int len(char *str)
{
int c=0;
while(*str++!='\0')
c++;
return c;
}
int count_pair(char *str,int n)
@gallirohik
gallirohik / queue.c
Created March 19, 2018 19:11
implemented queue using stack
#include <stdio.h>
#include <stdlib.h>
struct qnode
{
int data;
struct qnode *next;
};
typedef struct qnode* qptr;
qptr front=NULL,rear=NULL;
int isempty(front)
@gallirohik
gallirohik / subset.c
Created April 16, 2018 17:10
generate subsets
#include <stdio.h>
#include <stdlib.h>
int add(int *a,int n)
{
int i;
i=n-1;
while(i>=0)
{
if(a[i]&1)
{
@gallirohik
gallirohik / swappair.c
Last active April 16, 2018 19:09
swap pair in a linked list
#include <stdio.h>
#include <stdlib.h>
struct tnode
{
int data;
struct tnode *link;
};
typedef struct tnode *tptr;
tptr insert(tptr first,int x)
{
#include <stdio.h>
#include <stdlib.h>
struct tnode
{
int data;
struct tnode *link;
};
typedef struct tnode *tptr;
tptr insert(tptr first,int x)
{
#include <stdio.h>
#include <stdlib.h>
struct tnode
{
int data;
struct tnode *link;
};
typedef struct tnode *tptr;
tptr insert(tptr first,int x)
{
#include <stdio.h>
#include <stdlib.h>
struct tnode
{
int data;
struct tnode *link;
};
typedef struct tnode *tptr;
tptr insert(tptr first,int x)
{
@gallirohik
gallirohik / Song.cpp
Created August 1, 2018 08:32
My Brand new MyplayList project
#include<iostream>
using namespace std;
class Song
{
private:string name;
string composer;
string gener;
float duration;
int id;
public:Song(string name,string composer,string gener,float duration);
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
void print(vector<vector<int>>mat )
{
int n=mat.size();
for(int i=0;i<n;i++)