[ create a new paste ] login | about

Cyn

Name: Oleg
Email:
Site/Blog: http://vk.com/unitrinum
Location: Odessa, Ukraine
Default language: C++
Favorite languages: C++
About: self-taugh C++

Saved pastes by Cyn:

C++, pasted on Sep 4:
1
2
3
4
5
    const size_t maxStringsInString = 6;
    std::vector< std::string > strings
    {
        "AAAA-AAAA-AAAA-Z1",
        "AAAA-AAAA-AAAA-Z2",
...
view (44 lines, 2 lines of output)
C++, pasted on Jun 14:
1
2
3
4
bool TestSomething(int left, int right)
{
    if (left > right )
        return true;
...
view (7 lines, 2 lines of output)
C++, pasted on Dec 18:
1
2
3
4
5
//current
#define ALGORITHMS_PERFOMANCE
#ifdef ALGORITHMS_PERFOMANCE

#include <iostream>
...
view (315 lines, 6 lines of output)
C++, pasted on Jul 11:
1
2
3
4
5
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <sstream>

#include <vector>
...
view (65 lines, 5 lines of output)
C++, pasted on May 6:
1
2
3
4
5
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <limits>
...
view (166 lines)
C++, pasted on Mar 2:
1
2
3
4
5
#include <iomanip>
#include <iostream>
#include <fstream>

#include <string>
...
view (197 lines)
C++, pasted on Aug 6:
1
2
3
4
5
// a->*b Member pointed to by b of object pointed to by a
// a.*b  Member pointed to by b of object a
class FooBar
{
public:
...
view (28 lines)
C++, pasted on Jun 14:
1
2
3
4
5
#include <iomanip>
#include <iostream>
#include <fstream>

#include <string>
...
view (188 lines)
C++, pasted on Apr 4:
1
2
3
4
5
#include <cstdlib>
 
int main()
{
    char* programname = "notepad.exe";
...
view (8 lines, 3 lines of output)
C++, pasted on Mar 31:
1
2
3
4
5
/*
http://habrahabr.ru/post/132014/

Операторы                         Рекомендуемая форма
Все унарные операторы             Член класса
...
view (9 lines)
C++, pasted on Mar 19:
1
2
3
4
5
// .NET Framework 4.5 http://msdn.microsoft.com/ru-ru/library/system.enum.getname(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1
// стандартными средствами плюсов: http://www.rsdn.ru/forum/cpp/2943251.all

namespace some_enum
{    
...
view (63 lines)
C++, pasted on Feb 12:
1
2
3
4
5
/*
Проблемы при встраивании функций
http://msdn.microsoft.com/ru-ru/library/78t98006.aspx

При использовании процедуры встраивания функций необходимо:
...
view (8 lines)
C++, pasted on Feb 11:
1
2
3
4
5
#define SET(x) {(x) = (x) ? 1 : 0;}

// . . .

int main {
...
view (10 lines)
C++, pasted on Feb 11:
1
2
3
// check if n (>0) is a power of 2: 
if ((n & (n - 1)) == 0) cout << "true";
else  cout << n << " is not power of 2";
view (4 lines)
C++, pasted on Feb 10:
1
2
3
4
5
//Эта терминология немного разнится в разных книжках, отчего у читателей в головах возникаех сумбур вместо музыки.
//Существует три независимых понятия для функций:
//• перегрузка/overload;
//• сокрытие/overleap (как видим, в вышеприведенной цитате из Прата оно названо переопределением\overriding);
//• замещение/overriding виртуальной функции (в некоторых книгах также называется переопределением\overriding).
view (5 lines, 1 comment)
C++, pasted on Feb 7:
1
2
3
4
5
// UML 

#include <iostream>

using namespace std;
...
view (38 lines)
C++, pasted on Jan 26:
1
2
3
4
5
// Ch. 20. Simple Text editor.
#include <iostream>
using std::istream;

#include <vector>
...
view (311 lines)
C++, pasted on Sep 20:
1
2
3
4
5
/*
	simple "Programming: Principles and Practice using C++" course header to
	be used for the first few weeks.
	It provides the most common standard headers (in the global namespace)
	and minimal exception/error support.
...
view (234 lines)
C++, pasted on Sep 4:
1
2
3
4
5
//-------------------------------------------------------
template<class T>
struct DataMember {
	void** data;
	DataMember() : data(0) {} 
...
view (31 lines)
C++, pasted on Aug 7:
1
2
3
4
5
// code.cpp
// exercize 18-11: figure out what is "skip-list" and realize one.

#include "common.h" // error, keep_window_open, default declarations
#include "List.h"
...
view (587 lines)
C++, pasted on Jul 23:
1
2
3
4
5
// exercize 18:(1-8,10)
// realize:
// char*str_dup(const char* ch),
// char* findx(const char* s, const char* x),
// int strcmp(const char* s1, const char* s2)
...
view (310 lines)
C++, pasted on Jul 18:
1
2
3
4
// exercize 18-1, 18-2 realize char* strdup(const char* ch), char* findx(const char* s, const char* x). don use [] operator, but use dereferencing * operator;

#include "std_lib_facilities.h"
#include "Vector.h"
...
view (136 lines)
C++, pasted on Jul 18:
1
2
3
4
5
// exercize 17-5: realize char* findx(const char* s, const char* x) that finds 1st appearance of string x in string s

#include "std_lib_facilities.h"

//-------------------------------------------------------
...
view (66 lines)
C++, pasted on Jul 18:
1
2
3
4
5
//some code from chapter 18.
// oveloaded bool is_palindrome(...)

#include "std_lib_facilities.h"
#include "Vector.h"
...
view (79 lines)
C++, pasted on Jul 12:
1
2
3
// exercize 17-10: learn realloc() and prevent overflow of the chat* array

#include "std_lib_facilities.h"
...
view (79 lines)
C++, pasted on Jul 11:
1
2
3
4
5
// exercize 17-7: realize dynamic array of char

#include "std_lib_facilities.h"

//-------------------------------------------------------
...
view (81 lines)
C++, pasted on Jul 10:
1
2
3
// exercize 17-2: get size of int, double and bool without using sizeof

#include "std_lib_facilities.h"
...
view (99 lines)
C++, pasted on Jul 10:
1
2
3
4
// exercize 17-4: realize char* strdup(const char*) that allocates C-type sctring at the free store


#include "std_lib_facilities.h"
...
view (21 lines)
C++, pasted on Jul 10:
1
2
3
4
// exercize 17-3: realize void to_lower(char* s)


#include "std_lib_facilities.h"
...
view (23 lines)
C++, pasted on Jul 5:
1
2
3
4
5
// exercize from interview

#include <iostream>

// - - - - - - - - - - - - - - - - - - - - - 
...
view (62 lines)
C++, pasted on Jul 5:
1
2
3
4
5
#include "std_lib_facilities.h"

//------------------------------------------------------------------------------

class Invalid {};
...
view (57 lines)
C++, pasted on Jul 4:
1
2
3
4
5
// Chapter 15. Exercise 10.

//------------------------------------------------------------------------------

#include "std_lib_facilities.h"
...
view (54 lines)
C++, pasted on Jul 2:
1
2
3
4
5
#include <iostream>

using namespace std;

struct A {
...
view (38 lines, 12 lines of output)
C++, pasted on Jun 25:
1
2
3
4
5
// Calculator.h
/*

	Grammatis:
 
...
view (154 lines)
C++, pasted on Jun 25:
1
2
3
4
5
//  Calculator.cpp

#include "Calculator.h"

//------------------------------------------------------------------------------
...
view (397 lines)
C++, pasted on Jun 17:
1
2
3
4
5
// Chapter 15. Exercise 10.

//------------------------------------------------------------------------------

#define _USE_MATH_DEFINES		// to use M_PI constanc (pi number)
...
view (205 lines)
C++, pasted on Jun 17:
1
2
3
4
5
// Chapter 15. Exercise 9.

//------------------------------------------------------------------------------

#define _USE_MATH_DEFINES		// to use M_PI constanc (pi number)
...
view (153 lines)
C++, pasted on Jun 12:
1
2
3
4
5
//------------------------------------------------------------------------------

#define _USE_MATH_DEFINES		// to use M_PI constanc (pi number)
#include "cmath"			  // get assess to trigonometric functions
#include "Simple_window.h"    // get access to our window library
...
view (262 lines)
C++, pasted on May 23:
1
2
3
4
5
//------------------------------------------------------------------------------

struct Star : Shape {
	Star(Point center, int vertices_number, int Radius, int step = 2, double firstVertexAngularPosition = 0.0)
		:	sides(vertices_number), rCircumCircle(Radius), m(step), thi(firstVertexAngularPosition)
...
view (96 lines)
C++, pasted on May 21:
1
2
3
4
5
//------------------------------------------------------------------------------

struct Right_triangle : Shape {
	Right_triangle(Point circumCircleCenter,
					int rCircumCircle, 
...
view (102 lines)
C++, pasted on May 21:
1
2
3
4
5
//------------------------------------------------------------------------------

struct Regular_polygon : Shape {
	Regular_polygon(Point Center, int sides_number, int radius) 
		:	rCircumCircle(radius), sides(sides_number)
...
view (67 lines)
C++, pasted on May 20:
1
2
3
4
5
this code draws whole superellipse 
     <pre>
//pseudocode
fl_begin_comlpex_polygon();
 for (int i=0; i<_points.size(); i++) 
...
view (7 lines)
C++, pasted on May 19:
1
2
3
4
5
int int_round(double d) {
	
	if (d >= 0) return floor(d+0.5);
	else return ceil(d-0.5);
}
view (5 lines)
C++, pasted on May 17:
1
2
3
4
//Part 2. Chapter 13. Exercise 8
//------------------------------------------------------------------------------

struct Hexagon : Shape {
...
view (56 lines)
C++, pasted on May 17:
1
2
3
4
5
//Part 2. Chapter 13. Exercise 6

//------------------------------------------------------------------------------

#define _USE_MATH_DEFINES		// to use M_PI constanc (pi number)
...
view (112 lines)
C++, pasted on May 17:
1
2
3
4
5
// new ver. of Arrow::Shape with fixed arrow size
 
//------------------------------------------------------------------------------
 
struct Arrow : Shape {
...
view (125 lines)
C++, pasted on May 15:
1
2
3
4
// version of Box:Shape with circle-arcs
// previous version of Box have ellipse-arcs (that depend on major and minor axes)

//------------------------------------------------------------------------------
...
view (123 lines)
C++, pasted on May 14:
1
2
3
4
5
//Part 2. Chapter 13. Exercise 2.

//------------------------------------------------------------------------------

struct Box : Shape {
...
view (116 lines)
C++, pasted on May 14:
1
2
3
4
5
//Part 2. Chapter 13. Exercise 3.

//------------------------------------------------------------------------------

struct Arrow : Shape {
...
view (73 lines)
C++, pasted on May 14:
1
2
3
4
5
//Part 2. Chapter 13. Exercise 5.

#include "Graph.h"

Point n(const Graph_lib::Rectangle& r) {
...
view (194 lines)
C++, pasted on May 3:
1
2
3
4
5
// Part 2. Chapter 12. Exercize 13. incomlete

//------------------------------------------------------------------------------

#define _USE_MATH_DEFINES		// to use M_PI constanc (pi number)
...
view (122 lines)
C++, pasted on May 2:
1
2
3
4
5
// Part 2. Chapter 12. Exercize 13. incomlete


#define _USE_MATH_DEFINES		// to use M_PI constanc (pi number)
#include "Simple_window.h"    // get access to our window library
...
view (127 lines)
C++, pasted on Apr 19:
1
2
3
4
5
// Part 2. Chapter 11. Excercize 4. 
#include "../../std_lib_facilities.h"


 int main() {
...
view (41 lines)
C++, pasted on Apr 19:
1
2
3
4
5
// Part 2. Chapter 11. Excercize 3. 
#include "../../std_lib_facilities.h"

int str_to_int(const string& s, string& base) {
	
...
view (56 lines)
C++, pasted on Apr 19:
1
2
3
4
5
// Part 2. Chapter 11. Excercize 2. 
#include "../../std_lib_facilities.h"

const vector<char>& get_vowel() {
	static vector<char> vowel;
...
view (65 lines)
C++, pasted on Apr 2:
1
2
3
4
5
// Part 2. Chapter 10. Excercize 12. add "from x" and "to y" commands, where x and y are filenames
#include "../../std_lib_facilities.h"
 
void calc_help(ostream& ost);
void calculate(istream& ist, ostream& ost);
...
view (468 lines)
C++, pasted on Apr 1:
1
2
3
4
5
// Part 2. Chapter 10. Excercize 12. use getline to get words from file
#include "../../std_lib_facilities.h"

int main ()
try {
...
view (30 lines)
C++, pasted on Apr 1:
1
2
3
4
// Part 2. Chapter 10. Excercize 9. write a program that read two files with words that
// were put in order and separated with white space
// and concatinate them to third file saving order of words
#include "../../std_lib_facilities.h"
...
view (53 lines)
C++, pasted on Apr 1:
1
2
3
4
5
// Part 2. Chapter 10. Excercize 8. write a program that read two files and concatinate them to third file
#include "../../std_lib_facilities.h"

int main ()
try {
...
view (46 lines)
C++, pasted on Apr 1:
1
2
3
4
// Part 2. Chapter 10. Exercize 7. change calculactor from Ch.7 to work with roman digits
#include "../../std_lib_facilities.h"
#include "Roman.h"
using Roman::Roman_int;
...
view (388 lines)
C++, pasted on Apr 1:
1
2
3
4
5
// Part 2. Chapter 10. Exercize 6. implement  class Roman_int Roman.h
/*
1		I	лат. unus		
5		V	лат. quinque
10		X	лат. decem
...
view (407 lines)
C++, pasted on Mar 27:
1
2
3
4
5
// Part 2. Chapter 10. Exercize 5. implement  print_year(ofs,ys[i])

#include "../../std_lib_facilities.h"
//
// This is example code from Chapter 10.11.2 "Reading structured values" of
...
view (308 lines)
C++, pasted on Mar 27:
1
2
3
4
5
// Part 2. Chapter 10. Exersize 2-3-4. store_temps.cpp, temp_stats.cpp
#include "../../std_lib_facilities.h"
#include "Randomization.h"
// to throw exeption if stream ist go bad(). ist.exceptions(ist.exceptions() | ios_base::badbit); 
//-----------------------------------------------------------------
...
view (134 lines)
C++, pasted on Mar 26:
1
2
3
4
5
// Part 2. Chapter 10. Exersize 1.
#include "../../std_lib_facilities.h"
// ist.exceptions(ist.exceptions() | ios_base:badbit); 
// helper
void end_of_loop(istream& ist, const char& term, const string& message) {
...
view (52 lines)
C++, pasted on Mar 26:
1
2
3
4
5
// Part 2. Chapter 10. Task!
#include "../../std_lib_facilities.h"
// ist.exceptions(ist.exceptions() | ios_base:badbit); 
// helper
void end_of_loop(istream& ist, const char& term, const string& message) {
...
view (101 lines)
C++, pasted on Mar 25:
1
2
3
4
5
// Part 2. Chapter 10. 
#include "../../std_lib_facilities.h"

int main ()
try {
...
view (20 lines)
C++, pasted on Mar 25:
1
2
3
4
// Part 1. Chapter 9. Exercize 12. change represantation of Date class
// Chrono.h

#include "../../std_lib_facilities.h"
...
view (329 lines)
C++, pasted on Mar 25:
1
2
3
4
5
// Part 1. Chapter 9. Exercise 13. Rational class
#include "../../std_lib_facilities.h"
class Rational {
public:
	class Invalid{}; // exeptions
...
view (119 lines)
C++, pasted on Mar 25:
1
2
3
4
5
// Part 1. Chapter 9. Exercise 14-15. class Money
#include "../../std_lib_facilities.h"
//--------------------------------------------------------------
namespace Money_operations {
//--------------------------------------------------------------
...
view (149 lines)
C++, pasted on Mar 22:
1
2
3
4
// Part 1. Chapter 9. Exercize 11. add next_work_day(), week_of_year() to Chrono
// Chrono.h

#include "../../std_lib_facilities.h"
...
view (278 lines)
C++, pasted on Mar 19:
1
2
3
4
5
// main.cpp
// Part 1. Chapter 9. Exercize 9-10. class Library
#include "Library.h"

int main ()
...
view (41 lines)
C++, pasted on Mar 19:
1
2
3
4
5
// Library.h
#include "Book.h"
#include "Patron.h"

//---------------------------------------------------------------------
...
view (106 lines)
C++, pasted on Mar 19:
1
2
3
4
5
// Patron.h
#include "../../std_lib_facilities.h"
//------------------------------------------------------------------------------

class Patron {
...
view (36 lines)
C++, pasted on Mar 19:
1
2
3
4
5
// Book.h
#include "../../std_lib_facilities.h"
#include "Chrono.h"
using namespace Chrono;
class Book {
...
view (114 lines)
C++, pasted on Mar 19:
1
2
3
4
5
// Chrono.h

#include "../../std_lib_facilities.h"

namespace Chrono {
...
view (154 lines)
C++, pasted on Mar 18:
1
2
3
4
5
// Part 1. Chapter 9. Exercize 7. add enum Genre to class Book
#include "../../std_lib_facilities.h"
#include "Chrono.h"
using namespace Chrono;
//------------------------------------------------------------------------------
...
view (130 lines)
C++, pasted on Mar 18:
1
2
3
4
5
// Chrono.h

#include "../../std_lib_facilities.h"

namespace Chrono {
...
view (151 lines)
C++, pasted on Mar 18:
1
2
3
4
5
// Part 1. Chapter 9. Exercize 6. implement class Book, add ==, !=, << operators
#include "../../std_lib_facilities.h"
#include "Chrono.h"
using namespace Chrono;
 
...
view (123 lines)
C++, pasted on Mar 18:
1
2
3
4
5
// Part 1. Chapter 9. Exercize 3. change Name_pairs::print() to global operator<< , implement != and == operators for Name_pairs

#include "../../std_lib_facilities.h"

class Name_pairs {
...
view (144 lines, 16 lines of output)
C++, pasted on Mar 18:
1
2
3
4
5
// Part 1. Chapter 9. Exercize 2. implement class Name_pairs

#include "../../std_lib_facilities.h"

class Name_pairs {
...
view (94 lines)
C++, pasted on Mar 16:
1
2
3
4
// Part 1. Chapter 8. Exercize 14
#include "../../std_lib_facilities.h"
const int MAX_INT = numeric_limits<int>::max();
const bool INCLUDE_END_OF_RANGE = true; // [a;b] or [a;b); used in rand_in_range(int, int)
...
view (182 lines)
C++, pasted on Mar 15:
1
2
3
4
5
// Part 1. Chapter 8. Exercize 13. modify print_until_s()
// [a;b) rand_in_range(int a, int b);
// my rand_in_range gives numbers from [a;b]

#include "../../std_lib_facilities.h"
...
view (131 lines)
C++, pasted on Mar 15:
1
2
3
4
5
// Part 1. Chapter 8. Exercize 10-11-12. 
#include "../../std_lib_facilities.h"

const int MAX_INT = numeric_limits<int>::max();
const bool INCLUDE_END_OF_RANGE = true; // [a;b] or [a;b); used in rand_in_range(int, int)
...
view (166 lines)
C++, pasted on Mar 14:
1
2
3
4
5
// Part 1. Chapter 8. Exercize 8 - 9. "simple" randint() [0:MAX_INT] and
// [a;b) rand_in_range(int a, int b);
// my rand_in_range gives numbers from [a;b]

// #include "../../std_lib_facilities.h"
...
view (63 lines, 100 lines of output)
C++, pasted on Mar 14:
1
2
3
4
5
// Part 1. Chapter 8. Exercize 7. Sort names and ages vectors.
#include "../../std_lib_facilities.h"

void read_data(vector<string>& v_names, vector<double>& v_ages)
{
...
view (70 lines)
C++, pasted on Mar 14:
1
2
3
4
5
// Part 1. Chapter 8. Exercize 6. Swap vector elements order for vector<string>
#include "../../std_lib_facilities.h"
 
void filling_vector(vector<string>& v)
{
...
view (52 lines)
C++, pasted on Mar 14:
1
2
3
4
5
// Part 1. Chapter 8. Exercize 5. Swap vector elements order. 002 std swap()
#include "../../std_lib_facilities.h"

void filling_vector(vector<int>& v)
{
...
view (44 lines, 9 lines of output)
C++, pasted on Mar 13:
1
2
3
4
5
// Part 1. Chapter 8. Exercize 5. Swap vector elements order.
#include "../../std_lib_facilities.h"

void filling_vector(vector<int>& v)
{
...
view (49 lines)
C++, pasted on Mar 13:
1
2
3
4
5
// Part 1. Chapter 8. Exercize 4.
#include "../../std_lib_facilities.h"

void print(vector<int>&, string&);
int fibonacci();
...
view (33 lines, 4 lines of output)
C++, pasted on Mar 13:
1
2
3
4
5
// Part 1. Chapter 8. Exersize 1. 

#include "../../std_lib_facilities.h"

void print(vector<int>&, string&);
...
view (52 lines, 4 lines of output)
C++, pasted on Mar 13:
1
2
3
4
5
/*

	Grammatis:
 
		calculation:
...
view (465 lines, 4 lines of output, 1 comment)