[ create a new paste ] login | about

Link: http://codepad.org/LtFn0CsC    [ raw code | output | fork ]

C++, pasted on Jan 4:
#include <iostream>
#include <string>
#include <vector>

class C {
  std::vector<char> line[2];
public:
  C(std::string s) {
    int j = 0;
    for (unsigned int i = 0; i < s.length(); i++)
      if (s[i] != ' ')
        line[(j++ % 2)].push_back(s[i]);
  }
  friend std::ostream &operator<<(std::ostream &s, C obj) {
    std::vector<char>::iterator p = obj.line[0].begin();
    for (;p != obj.line[0].end(); p++)
      s << *p << ' ';
    s << std::endl << ' ';
    p = obj.line[1].begin();
    for (;p != obj.line[1].end(); p++)
      s << *p << ' ';
    return s;
  }
};

int main() {
  C a("123456789"), b("The earth turns around the sun.");
  std::cout << a << std::endl;
  std::cout << b << std::endl;
  return 0;
}
/* end */


Output:
1
2
3
4
1 3 5 7 9 
 2 4 6 8 
T e a t t r s r u d h s n 
 h e r h u n a o n t e u . 


Create a new paste based on this one


Comments: