예제 #1
0
static inline void ReverseComplement(std::string &s) {
    int i, j;
    for (i = 0, j = s.length() - 1; i < j; ++i, --j) {
        std::swap(s[i], s[j]);
        s[i] = Complement(s[i]);
        s[j] = Complement(s[j]);
    }
    if (i == j) { s[i] = Complement(s[i]); }
}
예제 #2
0
파일: main.c 프로젝트: f2008700/BITS
int main()
{
	SmallSet S1, S2, S3;
	int x,M,N,i;
	/********** Create Set S1 **********/
	S1=CreateSet();
	printf("S1 set is \n");
	Print(S1);
	/********** Create Set S2 **********/
	S2=CreateSet();
	printf("S2 set is \n");
	Print(S2);
	
	printf("Enter the number of Elements in S1 and S2\n");
	scanf("%d%d",&M,&N);
	/********* Add Elements to S1 ******/
	printf("Add Elements to S1\n");
	for(i=0;i<M;i++)
	{
		printf("Enter the Element\n");
		scanf("%d",&x);
		S1=AddElement(x,S1);
	}
	printf("Add Elements to S2\n");
	for(i=0;i<N;i++)
	{
		printf("Enter the Element\n");
		scanf("%d",&x);
		S2=AddElement(x,S2);
	}
	printf("The Set S1 after Addition\n");
	Print(S1);
	printf("The Set S2 after Addition\n");
	Print(S2);
	printf("Enter the Element to Delete from S1\n");
	scanf("%d",&x);
	S1=RemoveElement(x,S1);
	printf("Union of S1 and S2 sets are\n");
	S3=Union(S1,S2);
	Print(S3);
	printf("Intersection of S1 and S2 sets are\n");
	S3=Intersect(S1,S2);
	Print(S3);
	printf("Complement of set S1 is\n");
	S3=Complement(S1);
	Print(S3);
	printf("Is set S1 EQUALS set S2 ?\n");
	if(Equals(S1,S2))
		printf("The Sets are EQUAL\n");
	else
		printf("The Sets are NOT EQUAL\n");
	printf("Enter the value for finding element\n");
	scanf("%d",&x);
	if(isElementOf(x,S1))
		printf("The value %d is AVAILABLE in S1\n",x);
	else
		printf("The value %d is NOT AVAILABLE in S1\n",x);

return 0;
}
예제 #3
0
string Reverse(const string& s)
{
    size_t size = s.size();
    string r(size, ' ');
    for ( size_t i = 0; i < size; ++i ) {
        r[i] = Complement(s[size-1-i]);
    }
    return r;
}
예제 #4
0
파일: vcValue.cpp 프로젝트: ahirOrg/ahir
string Sub(string s, string t) // s,t are assumed to be little-endian
{
  if(s.size() == 0)
    return("");

  string q = Complement(t);
  string z = Zero_String(t.size());
  z[0] = '1';
  
  string tc = Add(z,q);
  string result = Add(tc,s);
  return(result);
}
	CNcbiqnaBase Get( EStrand strand ) const { return ( strand == eStrand_neg ) ? Complement() : *this; }
	CIupacnaBase Get( EStrand strand ) const { return strand == eStrand_neg ? Complement() : *this; }