名表查找程序C++的 + 用指针法做数字逆置

来源:百度知道 编辑:UC知道 时间:2024/06/14 13:17:37
以上是两个程序 帮忙编写下 在这里先谢谢您——我的回答者了!谢谢

你是要逆转链表的还是逆转数组啊?描述清楚点
#include <iostream>
using namespace std;
class A
{
public :
int data;
A *next;
};

class B
{
public:
A *end;
A *head;
B()
{
head=new A();
head->next=NULL;
end=head;
}
~B()
{
delete head;

}
void addinfo(int d)
{
A *temp=new A();
temp->data=d;
temp->next=NULL;
end->next=temp;
end=temp;
}
void renode()//逆转链表
{
A *flag,*temp;
if(head->next==NULL) return;
flag=head->next;
while(flag->next)
{
temp=flag->next;
flag->next=flag->next->next;
temp->next=head->next;
head->next=temp;
}
}
void shownode()
{
A* flag;
flag=head->next;
while(flag)
{
cout<<