[code=c++]
#include<iostream>
#include<windows.h>
struct list{
int a;
list *next;
};
int main()
{
using namespace std;
list *h; // head
list *e; // end
list *t; // temp
int temp;
int o;
t = new list();
h =new list();
e = h;
e -> next = NULL;
cout << "How many do you want to create ?" << endl;
cin >> o;
cout << "Please enter number:";
cin >> temp;
h -> a = temp;
h -> next = e;
for(int j = 0 ;j < o -1;j++)
{
t = new list();
cout << "Please enter number:";
cin >> temp;
e -> next =t;
e = t;
}
t = h;
for(int i = 0;i < o && t != NULL;i++)
{
cout << "No." << i+1 << " ";
cout << &t << " " << t -> a <<endl;
}
system("pause");
return 0;
}
[/code]
uj5u.com熱心網友回復:
for(int i = 0;i < o && t != NULL;i++)
{
cout << "No." << i+1 << " ";
cout << &t << " " << t -> a <<endl; // t+i, 不然t沒變
}
uj5u.com熱心網友回復:
噢,這樣啊......懂了!謝謝!
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/94421.html
標籤:新手樂園
