Skip to content

Instantly share code, notes, and snippets.

@samagragupta
Created January 27, 2020 17:58
Show Gist options
  • Save samagragupta/8ea001bf40c561a5263d50fecf484121 to your computer and use it in GitHub Desktop.
Save samagragupta/8ea001bf40c561a5263d50fecf484121 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
const int MAX=26;
int main()
{
int k,n,m;
cout<<"k=";
cin>>k;
cout<<"n=";
cin>>n;
cout<<"m=";
cin>>m;
set<char> v;
int i,z;
for(i=0;v.size()!=n+1;i++)
{
srand(time(NULL));
char alphabet[MAX] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z' };
// z=i+97;
// char c=char(z);
// v.push_back(c);
char c = alphabet[rand() % MAX];
v.insert(c);
}
int flag=0;
string s;
auto p=v.begin();
auto check=v.rbegin();
for(i=0;i<m;i++)
{
s+=" ( ";
for(int j=0;j<k;j++)
{
if((*p)==(*check))
{
p=v.begin();
s+="~";
}
if(flag==0)
{
// s+=(*p);
if(j==2)
{
s+="~";
s+=(*p);
}
else
s+=(*p);
if(j!=k-1)
s+=" & ";
flag=1;
}
else
{
if(i==2)
{
s+="~";
s+=(*p);
}
else
s+=(*p);
if(j!=k-1)
s+=" | ";
flag=0;
}
p++;
}
s+=" ) ";
if(i!=m-1)
s+=" | ";
}
cout<<s;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment