help in string combinations

hii

I have a list having m1 m2 m3........ m922

and in each there are a1 a2 a3 a4 are there like
m1=a1 a2 a3 a4 a5 a6
m2=a1 a2 a3 a4 a5 a6
m3=a1 a3 a5 a7 a8 a2

etc

and i want this as

m1=a1 a2 a3 a4 a5 a6
a2 a3 a4 a5 a6 a1
a3 a1 a2 a4 a5 a6
a4 a1 a2 a3 a5 a6
m2 =a1 a2 a3 a4 a5 a6
a2 a3 a4 a5 a6 a1
a3 a1 a2 a4 a5 a6
a4 a1 a2 a3 a5 a6

and so on please help



test.txt

Maya Machhindar#G Timbe#Durga Khote#Vinayak#Mohini#Baburao Pendharkar#Leela#Purohit#Nimabalkar#Hira Bai#



I have tried till this


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 #include <iostream>
#include <string>
#include <sstream>
#include <fstream>
 int main(){
    //load the text file and put it into a single string:
    std::ifstream in("test.txt");
    std::stringstream buffer;
    buffer << in.rdbuf();
    std::string test = buffer.str();
    std::cout << test << std::endl << std::endl;
    //create variables that will act as "cursors". we'll take everything between them.
    size_t pos1 = 0;
    size_t pos2;
    //create the array to store the strings.
    std::string str[50];
    for (int x=0; x<=20; x++){
        pos2 = test.find("#", pos1); //search for the bar "|". pos2 will be where the bar was found.
        str[x] = test.substr(pos1, (pos2-pos1)); //make a substring, wich is nothing more 
                                              //than a copy of a fragment of the big string.
        std::cout << str[x] << std::endl;
       // std::cout << "pos1:" << pos1 << ", pos2:" << pos2 << std::endl;
      pos1 = pos2+1; // sets pos1 to the next character after pos2. 
                         //so, it can start searching the next bar |.
    }
 }
You have to better explain what you are doing.
It looks like he wants to split a string, first on spaces, then on hashes (#).

I recommend reading the string using >> and placing each substring in a vector<string>. Each element of the vector represents one of the sublists.

You can then pass each substring off to another function that will split it up and print it like you want.

Is this what you are looking to do?
yes i want to split it as well want all possible cobnations of a1.... an to be printedjavascript:editbox1.editPreview()
You keep using the word "combinations", which suggests a specific reordering.

For example, every possible combination of 1,2,3 is:
1,2,3
1,3,2
2,1,3
2,3,1
3,1,2
3,2,1

Likewise, splitting a string at all possible combinations suggests something like:
Khote#Vinayak#Mohini#Baburao
Khote  Vinayak#Mohini#Baburao
Khote#Vinayak  Mohini#Baburao
Khote#Vinayak#Mohini  Baburao
Khote  Vinayak  Mohini#Baburao
Khote  Vinayak#Mohini  Baburao
Khote#Vinayak  Mohini  Baburao
Khote  Vinayak  Mohini  Baburao

I don't know what you are trying to do with the javascript.
yes exactly like this
Likewise, splitting a string at all possible combinations suggests something like:
Khote#Vinayak#Mohini#Baburao
Khote Vinayak#Mohini#Baburao
Khote#Vinayak Mohini#Baburao
Khote#Vinayak#Mohini Baburao
Khote Vinayak Mohini#Baburao
Khote Vinayak#Mohini Baburao
Khote#Vinayak Mohini Baburao
Khote Vinayak Mohini Baburao
Topic archived. No new replies allowed.