Subscribe Us

Responsive Advertisement

Advertisement

project jabo

Project jabo by ujjal roy



#include<bits/stdc++.h>

#include<conio.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using namespace __gnu_pbds;

#define ll long long int

#define endl "\n"

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

vector<ll>grp[1000000];

ll vis[1000000];

ll parent[1000000];

string source,destination;

map<string,ll>code;

map<ll,string>decode;

map<pair<ll,ll>,double>distancee;

map<pair<ll,ll>,string>medium;

map<pair<ll,ll>,string>timee;

map<pair<ll,ll>,string>short_n;

ll code_val=0;

void input();

void decision();

void report();

void contact();

void path_add();


void home()

{

    system("cls");


    printf("1.Search path\n");

    printf("2.Add path\n");

    printf("3.Add Report\n");

    printf("4.Contact\n");

    printf("Enter your choose : ");

    int choose;

    cin>>choose;


    if(choose==1)

    {

        input();



    }

    else if(choose==2)

    {


        path_add();

    }

    else if(choose==3)

    {

        report();

    }

    else if(choose==4)

    {

        contact();

    }

    else

    {

        system("cls");

        printf("Wrong choose\n");

        getch();

        decision();

    }



}

void path_add()

{


    while(1)

    {

        system("cls");

        printf("Enter 0 for go to home or press any digit to continue add path: ");

        char choose;

        cin>>choose;

        if(choose=='0')

        {

            home();

        }

        system("cls");

        printf("the path input formate.\n");

        printf("If we want to go From A to E throw the path B , C , D .the input will be\n\n");

        printf("A B(first destination) Medium Distance Time(for example 1_hour) ShORT NOTE\n\n");

        printf("B C(Second destination) Medium Distance Time ShORT NOTE\n\n");

        printf("C D(Third destination) Medium Distance Time ShORT NOTE\n\n");

        printf("D E(final destination) Medium Distance Time ShORT NOTE\n\n");

        printf("Please don't use space for writing short note and time use under_score\n");

        printf("\t...example Go_to_Right_side_for_bus_stand for time 1_hour_30_min\n\n\n");

        string s1,d1,m1,short1,t1;

        double dis1;


        printf("Enter source : ");

        cin>>s1;

        printf("Enter Destination : ");

        cin>>d1;

        printf("Enter Medium : ");

        cin>>m1;

        printf("Enter distance(approximately) : ");

        cin>>dis1;

        printf("Needed time (approximately) : ");

        cin>>t1;

        printf("please write short note above example : ");

        cin>>short1;

        ofstream fout;

        fout.open("allinput.txt",ios::app);

        fout<<s1<<" "<<d1<<" "<<m1<<" "<<dis1<<" "<<t1<<" "<<short1<<endl;

        fout.close();


        getch();


    }





}

void decision()

{


    printf("1.home page\n");

    printf("2.exit\n");

    ll choose;

    cin>>choose;

    if(choose==1)

    {

        home();

    }

    else if(choose==2)

    {

        return;

    }

    else

    {

       printf("Error choose \n");

      getch();

      decision();

    }


}

void result()

{

    system("cls");

    ll desti;

    desti=code[destination];

    if(vis[desti]==0)

    {

        printf("I apologize to you.In my data base the path is not connect right now.\n");

        printf("Every moment my data base are on updating.Hopefully you will got your path soon\n");

        printf("I request you .when you will know the path please Add the path in my Data base.\n");

        printf("It will be helpful for other\n");

        printf("Thank you for use me.\nI am always ready to help you\n");

        return;


    }

    else

    {

        vector<ll>ans;

        ans.push_back(desti);

        while(parent[desti]!=-1)

        {

            desti=parent[desti];

            ans.push_back(desti);


        }

        reverse(ans.begin(),ans.end());

        if(ans.size()<=1)

        {

            printf("Same place you no need to go\n");

            printf("Thank you .I am always ready to help you\n");

        }

        printf("You will go bellow the path : \n");

        for(ll i=0; i<ans.size()-1; i++)

        {

            ll u,v;

            u=ans[i];

            v=ans[i+1];

            //cout<<decode[u]<<"-->>"<<decode[v]<<" By "<<medium[ {min(u,v),max(u,v)}]<<endl;

            string temp1,temp2,temp3;

            temp1=decode[u];

            temp2=decode[v];

            temp3=medium[ {min(u,v),max(u,v)}];

            char arr1[(ll)temp1.size()+1];

            char arr2[(ll)temp2.size()+1];

            char arr3[(ll)temp3.size()+1];

           ll j;

            for(j=0;j<temp1.size();j++)

            {

                arr1[j]=temp1[j];

            }

            for(j=0;j<temp2.size();j++)

            {

                arr2[j]=temp2[j];

            }

            for(j=0;j<temp3.size();j++)

            {

                arr3[j]=temp3[j];

            }

            printf("%s ----> %s----> By %s\n",arr1,arr2,arr3);


        }

    }

    getch();

    decision();

}

void bfs(ll nod)

{

    queue<ll>q;

    q.push(nod);

    vis[nod]=1;

    parent[nod]=-1;

    while(!q.empty())

    {

        ll node;

        node=q.front();

        q.pop();

        for(ll i=0; i<grp[node].size(); i++)

        {

            ll child;

            child=grp[node][i];

            if(vis[child]==0)

            {

                parent[child]=node;

                vis[child]=1;

                q.push(child);


            }

        }

    }




}

void input()

{

    string t1,t2,medi,time1,short1;

    double dis1;

    ifstream fin;

    fin.open("allinput.txt");

    while(!fin.eof())

    {

        ll u,v;

        fin>>t1>>t2>>medi>>dis1>>time1>>short1;

        // cout<<t1<<" "<<t2<<endl;

        if(code[t1]==0)

        {

            code_val++;

            code[t1]=code_val;

            decode[code_val]=t1;


        }

        if(code[t2]==0)

        {

            code_val++;

            code[t2]=code_val;

            decode[code_val]=t2;

        }

        u=code[t1];

        v=code[t2];

        grp[u].push_back(v);

        grp[v].push_back(u);

        medium[ {min(u,v),max(u,v)}]=medi;

        distancee[{min(u,v),max(u,v)}]=dis1;

        timee[{min(u,v),max(u,v)}]=time1;

       short_n[{min(u,v),max(u,v)}]=short1;

    }


    fin.close();

    system("cls");

    printf("Enter your Source  : ");

    cin>>source;

    printf("\nEnter your Destination : ");

    cin>>destination;

    if(code[source]==0)

    {

        cout<<"Source not found\n";

        return ;

    }

    if(code[destination]==0)

    {

        cout<<"Destination not found\n";

        return ;

    }

    ll source_node;

    source_node=code[source];

    bfs(source_node);//if we want to change our feature just modify the functin

    result();

}

void report()

{

    system("cls");

    string s;

    cin.ignore();

    printf("Enter your report/comment : ");

    getline(cin,s);

    ofstream fout;

    fout.open("allreport.txt",ios::app);

    fout<<s<<"\n";


    system("cls");

    printf("Report successfully add.\n");

    fout.close();

    getch();

    decision();

}


void contact()

{

    system("cls");

    printf("my author email is : jabo1@gmail.com\n");

    printf("Thank you\n");

    getch();

    decision();

}


int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);


     home();


    return 0;


}



Post a Comment

0 Comments