-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsubarray_of_string.cpp
More file actions
50 lines (44 loc) · 1014 Bytes
/
subarray_of_string.cpp
File metadata and controls
50 lines (44 loc) · 1014 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//subarray substring linked lists file stream c_str gcd
// CPP program to count words in a string
// using stringstream.
#include <bits/stdc++.h>
using namespace std;
void subset_strings(string n,string cur ,int index)
{
if(index==n.length())
{
cout<<cur<<" ";
return;
}
subset_strings(n,cur,index+1);
subset_strings(n,cur+n[index],index+1);
}
void subarray(int arr[],int N,vector<int> p,int index)
{
if(index==N)
{
if(p.size()==0){
cout<<"{ } "<<" ";
}
else{
cout<<"{";
for(auto x:p)
{
cout<<x<<",";
}
cout<<"}"<<" ";
}
return;
}
subarray(arr,N,p,index+1);
p.push_back(arr[index]);
subarray(arr,N,p,index+1);
}
int main()
{
// string s="ABC";
// subset_strings(s," ",0);
int arr[]={1,2,3};
vector<int> x;
subarray(arr,3,x,0);
}