怎样用链表储存的矩阵顺时针旋转90度输出??
#include <iostream>
using namespace std;
typedef struct LinkNode
{
int x;
int y;
int data;
LinkNode* next;
}Node;
int main()
{
int m;
int n;
int data;
Node * head=new Node;
Node * p=new Node;
head->next=p;
cout<<"输入行号和列号"<<endl;
cin>>m>>n;
for(int i=0; i<m; i++)
for(int j=0; j<n; j++)
{
cin>>data;
p->x=i;
p->y=j;
p->data=data;
p->next=new Node;
p=p->next;
}
p=NULL;
p=head->next;
while(p->next){
cout<<p->data<<" ";
if(p->y==n-1) cout<<endl;
p=p->next;
}
cout<<endl;
system("pause");
return 0;
}
这是建好的链表