Switch to full style
C++ code examples
Post a reply

reverse list

Thu Nov 13, 2008 7:17 pm

Reverse a list using C++.
cpp code
#include <iostream>
#include <cassert>
#include <list>
#include <string>
#include <algorithm> // for reverse
using namespace std;

int main()
{
string s("asdfg");


list<char> list1(s.begin(), s.end());
list<char>::iterator i;

for (i = list1.begin(); i != list1.end(); ++i)
cout << *i;


reverse(list1.begin(), list1.end());

for (i = list1.begin(); i != list1.end(); ++i)
cout << *i;


return 0;
}
/*
asdfggfdsa
*/




Post a reply
  Related Posts  to : reverse list
 Java Reverse Engineering Tutorial.pdf     -  
 reverse ,length of strings as number of bytes     -  
 Return an array with elements in reverse order     -  
 recursive string reversal- reverse string     -  
 iterator on list     -  
 list swap in C++     -  
 Implementation of List     -  
 List interface     -  
 List all database in php     -  
 List C++ implementation     -  

Topic Tags

C++ Data Structures