当前位置: 首页>>代码示例>>C++>>正文


C++ Reverse函数代码示例

本文整理汇总了C++中Reverse函数的典型用法代码示例。如果您正苦于以下问题:C++ Reverse函数的具体用法?C++ Reverse怎么用?C++ Reverse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Reverse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: VisitExpr

 void VisitExpr( const  SymbolicExpr& v) 
         { switch (v.GetOpType()) { 
            case SYMOP_MULTIPLY:
            case SYMOP_PLUS:
                  Default0(); break;
            case SYMOP_MIN:
            case SYMOP_MAX:
                  Default1(v1,v2);
                  if (result == REL_UNKNOWN)
                     result = (index == 1)? SelectCompare(v1,v,GetFunc())(v2)
                                 : Reverse(SelectCompare(v2,v,GetFunc())(v1)); 
                     break;
            default: 
                  assert(false);
           }  
         }
开发者ID:billhoffman,项目名称:rose-develop,代码行数:16,代码来源:SymbolicOperator.C

示例2: Test

// ==================== Test Code ====================
ListNode* Test(char* testName, ListNode* pHead, unsigned int k)
{
    if(testName != NULL)
        printf("====%s begins: ====\n", testName);

    printf("The original list is: ");
    PrintList(pHead);
    
    printf("The reversed list is: ");
    ListNode* pReversedHead = Reverse(pHead, k);
    PrintList(pReversedHead);

    printf("\n\n");

    return pReversedHead;
}
开发者ID:brian-smith723,项目名称:DesignPatterns,代码行数:17,代码来源:049_ReverseListInGroups.cpp

示例3: main

int main(int argc, const char *argv[])
{
    char array[100] = "I am a student";
    char *pbegin, *pend;
    char *pdate;
    pbegin = pend = array;

    Reverse(pbegin, pend);
    printf("Now, the string is :\n");
    printf("%s\n", array);
    pdate = array;
    Reverse_sentense(pdate);
    
    printf("%s\n", array);
    return 0;
}
开发者ID:happychen,项目名称:embedded,代码行数:16,代码来源:word_inverse.c

示例4: main

int main()
{
    AreEqual("dcba", Reverse("abcd"));
    AreEqual("cba", Reverse("abc"));
    AreEqual("aA", Reverse("Aa"));
    AreEqual("airaM", Reverse("Maria"));
    AreEqual("xelA", Reverse("Alex"));
    AreEqual("", Reverse(""));

    return 0;
}
开发者ID:mboghiu,项目名称:try,代码行数:11,代码来源:main.cpp

示例5: main

int main() {
	struct Node* head; // local variable
	int n, i, x;

	printf("Enter the number of elements in the list> ");
	scanf("%d", &n);

	for(i = 0; i < n; i++) {
		printf("\nEnter element %d> ", i + 1);
		scanf("%d", &x);
		head = Insert(head, x);
	}
	Print(head);
	head = Reverse(head);
	Print(head);
return 0;
}
开发者ID:nitinprakash96,项目名称:Data-structures,代码行数:17,代码来源:reverse+list.c

示例6: main

int main(){
	int i;
	Node * sFirst=NULL;
	Node * sHead=sFirst;
	for (i = 0; i < 9; ++i)
	{
		sFirst=Insert(i,sFirst);
	}
	printf("Before Reversing;\n");
	Myprint(sFirst);
	printf("After Reversing;\n");
	sFirst=Reverse(sFirst,NULL);
	Myprint(sFirst);



}
开发者ID:mohakraaj,项目名称:InterestingAlgos,代码行数:17,代码来源:LinkedList.c

示例7: ReverseSentence

void ReverseSentence (char* str) {
    if (NULL == str || *str == 0) {
        return;
    }
    char* pBegin = str;
    char* pEnd = str;

    while (*pBegin != '\0') {
        if (*pBegin == ' ') {
            ++pBegin, ++pEnd;
        } else if (*pEnd == ' ' || *pEnd == '\0') {
            Reverse(pBegin, pEnd - 1);
            pBegin = pEnd;
        } else {
            ++pEnd;
        }
    }
}
开发者ID:ShiboBrady,项目名称:program_practise,代码行数:18,代码来源:42_reverse_word.cpp

示例8: main

int main()
{
  List L = Create();
  ElementType e;

  e = 3;
  InsertAtHead(e, L);
  e = 2;
  InsertAtHead(e, L);
  e = 1;
  InsertAtHead(e, L);

  PrintList(L);
  L = Reverse(L);
  PrintList(L);

  return 0;
}
开发者ID:Shitaibin,项目名称:DSAAC,代码行数:18,代码来源:3.12.a.c

示例9: itoa

void itoa(int n,char s[],int b)
{
	void Reverse(char s[]);
	int i,sign;
	sign=n;
	i=0;
	do
	{
		s[i++]=abs(n%10)+'0';
	}
	while((n/=10)!=0);
	if(sign<0)
		s[i++]='-';
	while(i<b)
		s[i++]=' ';
	s[i]='\0';
	Reverse(s);
}
开发者ID:hanxiaomax,项目名称:KRC_exercise,代码行数:18,代码来源:cp3-6.c

示例10: Id

void RelayForwarder::IncomingData(const Request &notification)
{
    QVariantHash msg = notification.GetData().toHash();

    Id destination = Id(msg.value("to").toString());
    if(destination == Id::Zero()) {
        qWarning() << "Received a forwarded message without a destination.";
        return;
    }

    QStringList been = msg.value("been").toStringList();
    if(destination == _local_id) {
        if(been.size() == 0) {
            qWarning() << "Received a forwarded message without any history.";
            return;
        }

        Id source = Id(been[0]);
        if(source == Id::Zero()) {
            qWarning() << "Received a forwarded message without a valid source.";
        }

        QSharedPointer<ForwardingSender> *psender = _cache.take(source);
        if(!psender || (*psender)->GetReverse().isEmpty()) {
            if(psender) {
                delete psender;
            }
            psender = new QSharedPointer<ForwardingSender>(
                new ForwardingSender(GetSharedPointer(), _local_id, source, been));
        }

        QSharedPointer<ForwardingSender> sender(*psender);
        _cache.insert(source, psender);

        _rpc->HandleData(sender, msg.value("data").toByteArray());
        return;
    }

    QStringList reverse = msg.value("reverse").toStringList();
    QByteArray data = msg.value("data").toByteArray();
    if(reverse.isEmpty() || !Reverse(destination, data, been, reverse)) {
        Forward(destination, data, been);
    }
}
开发者ID:benjaminp,项目名称:Dissent,代码行数:44,代码来源:RelayForwarder.cpp

示例11: FFT1DOnce

void FFT1DOnce(long direction, long M, long N, double *u, double *x)
{
  long j; 
  long k; 
  long q; 
  long L; 
  long r; 
  long Lstar;
  double *u1; 
  double *x1; 
  double *x2;
  double omega_r; 
  double omega_c; 
  double tau_r; 
  double tau_c; 
  double x_r; 
  double x_c;

  Reverse(N, M, x);

  for (q=1; q<=M; q++) {
    L = 1<<q; r = N/L; Lstar = L/2;
    u1 = &u[2*(Lstar-1)];
    for (k=0; k<r; k++) {
      x1 = &x[2*(k*L)];
      x2 = &x[2*(k*L+Lstar)];
      for (j=0; j<Lstar; j++) {
	omega_r = u1[2*j]; 
        omega_c = direction*u1[2*j+1];
	x_r = x2[2*j]; 
        x_c = x2[2*j+1];
	tau_r = omega_r*x_r - omega_c*x_c;
	tau_c = omega_r*x_c + omega_c*x_r;
	x_r = x1[2*j]; 
        x_c = x1[2*j+1];
	x2[2*j] = x_r - tau_r;
	x2[2*j+1] = x_c - tau_c;
	x1[2*j] = x_r + tau_r;
	x1[2*j+1] = x_c + tau_c;
      }
    }
  }
}
开发者ID:dpac-vlsi,项目名称:Sigil,代码行数:43,代码来源:fft.C

示例12: main

int main()
{
	int i,n;
	char s[80],key[12],encrypt[80];              //输入串,密钥,加密后的串
	scanf("%s",key);
	getchar();                                            //吃掉输入密钥后的那个回车
	GeneAlphabet();                                  //产生字母表
	Reverse(key);                                       //将密钥key反转
	GetCharMap(key);                               //得到字母表的加密字符的对应表
	while(1)
	{
		gets(s);                                            //得到每行要加密的串
		if(strcmp(s,"#") == 0) break;            //如果输入#号则终止程序
		strcpy(encrypt,"");                            //将加密后的串先清空
		Encrypt(s,key,encrypt);                     //加密
		puts(encrypt);                                  //输出
	}
	return 0;
}
开发者ID:jindongwang,项目名称:BUAA-Recommend-Graduate-Test,代码行数:19,代码来源:406-加密字符串.cpp

示例13: Reverse

void Reverse (Stack *L) 
{
    assert(L != NULL); //precondition for empty list
    
    StackNode *head, *remainder;
    Stack tempRest; //temporary list for recursion function
    
    head = L->first;
    remainder = head->next; //rest of list to be reversed
    if (remainder == NULL)
        return;
    tempRest.first = remainder;
    
    Reverse(&tempRest); //calls itself with remainder of list
    
    head->next->next = head;
    head->next = NULL;    
    L->first = tempRest.first; //attaches head
}
开发者ID:jns0987654321,项目名称:CIS_2520,代码行数:19,代码来源:StackImplementation.c

示例14: main

int main()
{
//	freopen("1.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	a[0]=a[n+1]=INF;
	root=build(0,n+2);
	root->p=null;
	scanf("%d",&m);
	while(m--)
	{
		int x,y,k;
		char s[20];
		scanf("%s",s);
		switch(s[0])
		{
			case 'A':scanf("%d%d%d",&x,&y,&k);
					 Add(x,y,k);
					 break;
			case 'I':scanf("%d%d",&x,&k);
					 Insert(x,k);
					 break;
			case 'D':scanf("%d",&x);
					 Delete(x);
					 break;
			case 'M':scanf("%d%d",&x,&y);
					 printf("%d\n",Min(x,y));
					 break;
			case 'R':if(s[3]=='E')
					 {
					 	scanf("%d%d",&x,&y);
						Reverse(x,y);
					 }
					 else
					 {
					 	scanf("%d%d%d",&x,&y,&k);
						Revolve(x,y,k);
					 }
		}
	}
	return 0;
}
开发者ID:RunningTime,项目名称:templates,代码行数:43,代码来源:splay2.cpp

示例15: swapPairs

struct ListNode* swapPairs(struct ListNode* head) {
    
    if(!head || head->next == NULL)
    {
        return head;
    }
    
    struct ListNode* rest;
    struct ListNode* last;
    
    rest = head->next->next;
    
    last = Reverse(&head);
    
    last->next = swapPairs(rest);
    
    return head;
    
}
开发者ID:rakeshakkera03,项目名称:Coding,代码行数:19,代码来源:SwapNodesInPairs.cpp


注:本文中的Reverse函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。