Kompetensi : Mahasiswa mampu
menggunakan rutin yang ada dalam
bahasa C++ menggunakan STL
#2.
Kompetensi 2, 3
• #include <iostream.h> • #include <list.h>
• int main()
• {
• list<char> coll; // list container for character elements
• // append elements from 'a' to 'z'
• for (char c='a'; c<='z'; ++c) {
• coll.push_back(c);
• }
• system("PAUSE"); • return 0;
Kompetensi 2, 3
• #include <iostream.h> • #include <list.h>
• int main() • {
• list<char> coll; // list container for character elements • // append elements from 'a' to 'z'
• for (char c='a'; c<='z'; ++c) { • coll.push_front(c);
• }
• system("PAUSE"); • return 0;
Kompetensi 2,3,4
• #include <iostream.h> • #include <list.h>
• int main() • {
• list< ………..> coll; // list container for integer elements • // append elements from 1 to 20
• for (int c=1; c<=20; ++c) { • coll.push_back(c);
• }
• system("PAUSE"); • return 0;
Kompetensi 2,3,4
• #include <iostream.h> • #include <………> • int main()
• {
• list<int> coll; // list container for integer elements • // append elements from 1 to 20
• for (int c=1; c<=20; ++c) { • coll.push_back(c);
• }
• system("PAUSE"); • return 0;
• }
1 2 3 4 5 6 7 8 9 10 11 ……….. 20 Di
Kompetensi 2,3,4
• #include <iostream.h> • #include <………> • int main()
• {
• list<int> coll; // list container for integer elements • // append elements from 1 to 20
• for (int c=1; c<=20; ++c) { • coll.____________(c); • }
• system("PAUSE"); • return 0;
• }
20 19 18 17 16 15 14 ….. 5 4 3 2 1 Di