本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
}
示例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;
}
示例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);
}
示例10: Id
void RelayForwarder::IncomingData(const Request ¬ification)
{
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);
}
}
示例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;
}
}
}
}
示例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;
}
示例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
}
示例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;
}
示例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;
}