Professional Documents
Culture Documents
Assignment-2 BCS: Name-Pavan Kumar M Pujari ROLL NO-056
Assignment-2 BCS: Name-Pavan Kumar M Pujari ROLL NO-056
ROLL NO-056
1.
#include <iostream>
#include <list>
#include <string>
#define max 4
using namespace std;
string strings1[max],strings2[max]; // define max string
class Graph {
int V;
list<int>* adj;
void printAllPathsUtil(int, int, bool[], int[], int&);
public:
Graph(int V); // Constructor
void addEdge(int u, int v);
void printAllPaths(int s, int d);
};
Graph::Graph(int V)
{
this->V = V;
adj = new list<int>[V];
}
}
return length;
}
void split1 (string str, char seperator)
{
int currIndex = 0, i = 0;
int startIndex = 0, endIndex = 0;
while (i <= len(str))
{
if (str[i] == seperator || i == len(str))
{
endIndex = i;
string subStr = "";
subStr.append(str, startIndex, endIndex - startIndex);
strings1[currIndex] = subStr;
currIndex += 1;
startIndex = endIndex + 1;
}
i++;
}
}
void split2 (string str, char seperator)
{
int currIndex = 0, i = 0;
int startIndex = 0, endIndex = 0;
while (i <= len(str))
{
if (str[i] == seperator || i == len(str))
{
endIndex = i;
string subStr = "";
subStr.append(str, startIndex, endIndex - startIndex);
strings2[currIndex] = subStr;
currIndex += 1;
startIndex = endIndex + 1;
}
i++;
}
}
// Driver program
int main()
{
string str1;
string str2 ;
cin>>str1;
cin>>str2;
char seperator = '/'; // space
split1(str1, seperator);
split2(str2, seperator);
cout <<" The split string is: ";
}
cout<<"\n";
cout<<" 0 \n";
cout<<" / \\ \n";
cout<<" 1 2 \n";
cout<<" \\ \n";
cout<<" 3 \n";
// Create a graph given in the above diagram
Graph g(4);
g.addEdge(0, 1);
g.addEdge(0, 2);
g.addEdge(1, 0);
g.addEdge(1, 2);
g.addEdge(2, 0);
g.addEdge(2, 1);
g.addEdge(2, 3);
g.addEdge(3, 2);
int s,d;
cout<<"enter source & destination no:";
cin>>s>>d;
cout << "Following are all different paths from " << s << " to " << d << endl;
g.printAllPaths(s, d);
return 0;
}