Pakistan Flag using C++ : For Loop

‪#‎include‬ #include void main(){clrscr();int x=20,z=x-14;for(int i=z-z;i<=x+x;i++){ cout<<"*";}cout<<endl;for(int j=z-z;j<=x;j++){cout<<"ÛÛÛÛÛÛÛÛÛÛ\t\t\t\t*\n";}for(int k=z-z;k<=x+x;k++){ cout<<"*";}gotoxy(x,z++); {cout<<" _**";}gotoxy(x,z++); {cout<<" *";}gotoxy(x,z++); {cout<<" * * ";}gotoxy(x,z++); {cout<<" ** ** **";}gotoxy(x,z++);{cout<<" *** *** ";}gotoxy(x,z++);{cout<<" ** * *";}gotoxy(x,z++);{cout<<" * ";}gotoxy(x,z++);{cout<<" *";}gotoxy(x,z++);{cout<<" ~**";}gotoxy(1,24);{for(int c=1;c<=21;c++)cout<<"**\n";}getch();}

Graph Adjacency Matrix using 2D-Array

#include #include void  main( ) { int i, j ,siz; clrscr(); int G[100][100]; cout<<" Enter the size of sequre Metrix  \n";cout<<" Enter Rows siz :"; cin>>i; cout<<" \n Enter Colums siz : "   ; cin>>j; siz=j;  for(i=0 ; i < siz  ; i++) for(j=0 ; j< siz ; j++) { G[i][j]=0; } int a; cout<<" \n Enter the No of Edges: "; cin>>a; cout<<" \n Enter the exact location whereContinue reading “Graph Adjacency Matrix using 2D-Array”

Graph Adjacency List using Link list

#include#include struct Adj_list{ int dest;struct Adj_list *next; };struct Adjlist{struct Adj_list *head; }; class Graph{int v;int i;public:struct Adjlist *array; Graph(int v){this->v=v;array=new Adjlist[v];array[i].head=NULL;} Adj_list *newAdj_list(int dest){ Adj_list *newnode =new Adj_list;newnode->dest=dest;newnode->next=NULL;return newnode;} void addedge(int src,int dest){ Adj_list *newnode=newAdj_list(dest); newnode->next=array[src].head;array[src].head=newnode;newnode=newAdj_list(src);newnode->next=array[dest].head;array[dest].head=newnode;} void display(){ int i;for(i=0; i< v; i++){Adj_list *pcrawl=array[i].head;cout<<" \n Adjancy List of vertex  "<<i<<" head"; while(pcrawl){cout< “<dest;pcrawl=pcrawl->next; }cout<<endl;} }};voidContinue reading “Graph Adjacency List using Link list”

DFS tree in C++

#include#includeint cost[10][10],i,j,k,n;int stack[10],top,v,visit[10],visited[10];void main(){clrscr();int m;cout <<"Enter no of vertices\Nodes: ";cin >> n;cout <<"\nEnter no of Edges: ";cin >> m;cout <<"\n\tEnter All EDGES Source & Distination\n";for(k=1;k<=m;k++){cout<<"\nEnter Source: ";cin >>i;cout<<"\nEnter Distination: ";cin>>j;cost[i][j]=1;cout<<"\n———————–\n";}cout <<"\nEnter initial vertex: ";cin >>v;cout <<"\nORDER OF VISITED VERTICES:\n";cout <<v<<" ";visited[v]=1;k=1;while(k<n){for(j=n;j>=1;j–)if(cost[v][j]!=0 && visited[j]!=1 && visit[j]!=1){visit[j]=1;stack[top]=j;top++;}v=stack[–top];cout<<v << " ";k++;visit[v]=0;visited[v]=1;}getch();}

BFS tree Code in C++

#include#includeint cost[10][10],i,j,k,n;int que[10],front,rare,v,visit[10],visited[10];void main(){clrscr();int m;cout <<"Enter no of vertices\ Nodes: ";cin >> n;cout <<"\nEnter no of Edges: ";cin >> m;cout <<"\n\tEnter All EDGES by source & destination\n";for(k=1;k<=m;k++){cout<<"\nEnter Source: ";cin >>i;cout<<"\nEnter Destination: ";cin>>j;cost[i][j]=1;cout<<"\n———————–\n";}cout <<"\nEnter initial vertex: ";cin >>v;cout <<"Visitied vertices:\n";cout << v<<" ";visited[v]=1;k=1;while(k<n){for(j=1;j<=n;j++)if(cost[v][j]!=0 && visited[j]!=1 && visit[j]!=1){visit[j]=1;que[rare++]=j;}v=que[front++];cout<<v << " ";k++;visit[v]=0;visited[v]=1;}getch();}

HAng MaN Game in C++

#include#include#include#include int a;void main(){ char ch[50],new1[50],word[50];cout<<"              ————————————————"<<endl;cout<<"                        Welcome To the HAng MaN Game "<<endl;cout<<"              ————————————————"<<endl<<endl;cout<<"                         |(((( Player OnE )))) |Continue reading “HAng MaN Game in C++”

AVL Balance Tree in C++

AVL TREE IMPLEMENTAION:#include#include#includestruct avl_node{    int data;    struct avl_node *left;    struct avl_node *right;}*root;int max(int a,int b){if (a>b){return a;}else { return b;}}class avlTree{    public: avlTree() {    root = NULL; }int height(avl_node *temp){    int h = 0;    if (temp != NULL)    { int l_height = height (temp->left); int r_height =Continue reading “AVL Balance Tree in C++”

Typedef in C++

The typedef-names are aliases for existing types, and are not declarations of new types. Typedef cannot be used to change the meaning of an existing type name (including a typedef-name). Once declared, a typedef-name may only be redeclared to refer to the same type again. Typedef names are only in effect in the scope whereContinue reading “Typedef in C++”

Red and Black Tree in C++

RED AND BLACK TREE: All the case’s of Insertion Deletion , Searching and Display ” Using typedef and Structure user define data types.Code in C++ ↓↓↓↓↓↓↓Code is Bellow ☺ ☻ ↓↓↓↓↓↓↓↓↓↓↓↓ Source code:Programming Seekerz :  ☺#include #include #include #include enum rbtree_node_color { RED, BLACK }; typedef struct rbtree_node_t {    void* key;    void* value;   Continue reading “Red and Black Tree in C++”