Simple2012

Untitled

Oct 18th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. #include "int_buffer.h"
  2. #include "int_sorted.h"
  3. #include <iostream>
  4. #include <string>
  5.  
  6. void f(int_buffer buf){
  7.     int j = 1;
  8.     for (int *i = buf.begin(); i != buf.end(); i++)
  9.     {
  10.         *i = j++;  
  11.     }
  12.     const int_buffer &btmp=buf; // const object to call correct begin & end.
  13.     for (const int *i = btmp.begin(); i != btmp.end(); i++)
  14.     {
  15.         std::cout << *i << std::endl;
  16.     }
  17. }
  18. void g(int_sorted buf){
  19.     for (size_t i = 0; i < 10; i++){
  20.         std::cout << "Position: " << buf.insert(i*191) << std::endl;
  21.     }
  22.     const int_sorted &btmp=buf; // const object to call correct begin & end.
  23.     for (const int *i = btmp.begin(); i != btmp.end(); i++)
  24.     {
  25.         std::cout << *i << std::endl;
  26.     }
  27. }
  28.  
  29. int main(int argc, char const *argv[])
  30. {
  31.     std::string choice, file;
  32.     std::cout << "\t -:: Welcome to MarcuS merge program::-" << std::endl;
  33.     while (true){ // Simple user interface
  34.         std::cout
  35.             << "Choose option" << std::endl
  36.             << "[1] -\t int_buffer" << std::endl
  37.             << "[2] -\t int_sorted - insert" << std::endl
  38.             << "[3] -\t Testing 1 and 2" << std::endl
  39.             << "[4] -\t Exit program" << std::endl;
  40.         std::getline(std::cin, choice);
  41.         std::cout << std::endl;
  42.  
  43.  
  44.         //Choice 1
  45.         if (choice.find('1') != std::string::npos){
  46.             int_buffer buf(10);
  47.             f(buf);
  48.  
  49.         //Choice 2
  50.         }else if(choice.find('2') != std::string::npos){
  51.             int_sorted buf(0, 0);
  52.             g(buf);
  53.            
  54.  
  55.         //Choice 3
  56.         }else if (choice.find('3') != std::string::npos){
  57.             std::cout << "woopwoop\n";
  58.  
  59.         //Choice 4
  60.         }else if(choice.find('4') != std::string::npos){
  61.             return 0;
  62.  
  63.         //Incorrect input
  64.         }else{
  65.             std::cout << "Please choose between [1], [2], [3] and [4]." << std::endl;
  66.         }
  67.     }
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment