Δημοσιεύτηκε: 25 Ιουν 2011, 20:10
Είχα κάποιο error με το πρόγραμμα σου κατά το compile.
Εγώ συνδύασα δύο οδηγούς:
- http://www.cplusplus.com/reference/stl/list/push_back/
- http://www.java2s.com/Code/Cpp/list/Use ... nalist.htm
Αποτέλεσμα:
Εγώ συνδύασα δύο οδηγούς:
- http://www.cplusplus.com/reference/stl/list/push_back/
- http://www.java2s.com/Code/Cpp/list/Use ... nalist.htm
Αποτέλεσμα:
- Κώδικας: Επιλογή όλων
#include <iostream>
#include <list>
using namespace std;
int main()
{
list<int> mylist;
list<int>::iterator p;
int myint = 1;
while (myint) {
cout << "Please enter some integers (enter 0 to end): ";
cin >> myint;
if (myint != 0) {
mylist.push_back(myint);
cout << "\n";
}
}
cout << "mylist stores " << (int) mylist.size() << " numbers.\n";
cout << "mylist variables:\n";
p = mylist.begin();
while(p != mylist.end()) {
cout << *p << endl;
p++;
}
return 0;
}