Cyn
|
codepad
|
|
Cyn
|
Saved pastes by Cyn:
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) |
//current
#define ALGORITHMS_PERFOMANCE
#ifdef ALGORITHMS_PERFOMANCE
#include <iostream>
|
view (315 lines, 6 lines of output) |
// 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) |
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <limits>
|
view (166 lines) |
// 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) |
/*
http://habrahabr.ru/post/132014/
Операторы Рекомендуемая форма
Все унарные операторы Член класса
|
view (9 lines) |
// .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) |
/*
Проблемы при встраивании функций
http://msdn.microsoft.com/ru-ru/library/78t98006.aspx
При использовании процедуры встраивания функций необходимо:
|
view (8 lines) |
// 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) |
//Эта терминология немного разнится в разных книжках, отчего у читателей в головах возникаех сумбур вместо музыки.
//Существует три независимых понятия для функций:
//• перегрузка/overload;
//• сокрытие/overleap (как видим, в вышеприведенной цитате из Прата оно названо переопределением\overriding);
//• замещение/overriding виртуальной функции (в некоторых книгах также называется переопределением\overriding).
|
view (5 lines, 1 comment) |
// Ch. 20. Simple Text editor.
#include <iostream>
using std::istream;
#include <vector>
|
view (311 lines) |
/*
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) |
//-------------------------------------------------------
template<class T>
struct DataMember {
void** data;
DataMember() : data(0) {}
|
view (31 lines) |
// 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) |
// 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) |
// 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) |
// 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) |
//some code from chapter 18.
// oveloaded bool is_palindrome(...)
#include "std_lib_facilities.h"
#include "Vector.h"
|
view (79 lines) |
// exercize 17-10: learn realloc() and prevent overflow of the chat* array
#include "std_lib_facilities.h"
|
view (79 lines) |
// exercize 17-7: realize dynamic array of char
#include "std_lib_facilities.h"
//-------------------------------------------------------
|
view (81 lines) |
// exercize 17-2: get size of int, double and bool without using sizeof
#include "std_lib_facilities.h"
|
view (99 lines) |
// 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) |
// exercize from interview
#include <iostream>
// - - - - - - - - - - - - - - - - - - - - -
|
view (62 lines) |
#include "std_lib_facilities.h"
//------------------------------------------------------------------------------
class Invalid {};
|
view (57 lines) |
// Chapter 15. Exercise 10.
//------------------------------------------------------------------------------
#include "std_lib_facilities.h"
|
view (54 lines) |
// Calculator.cpp
#include "Calculator.h"
//------------------------------------------------------------------------------
|
view (397 lines) |
// Chapter 15. Exercise 10.
//------------------------------------------------------------------------------
#define _USE_MATH_DEFINES // to use M_PI constanc (pi number)
|
view (205 lines) |
// Chapter 15. Exercise 9.
//------------------------------------------------------------------------------
#define _USE_MATH_DEFINES // to use M_PI constanc (pi number)
|
view (153 lines) |
//------------------------------------------------------------------------------
#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) |
//------------------------------------------------------------------------------
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) |
//------------------------------------------------------------------------------
struct Right_triangle : Shape {
Right_triangle(Point circumCircleCenter,
int rCircumCircle,
|
view (102 lines) |
//------------------------------------------------------------------------------
struct Regular_polygon : Shape {
Regular_polygon(Point Center, int sides_number, int radius)
: rCircumCircle(radius), sides(sides_number)
|
view (67 lines) |
this code draws whole superellipse
<pre>
//pseudocode
fl_begin_comlpex_polygon();
for (int i=0; i<_points.size(); i++)
|
view (7 lines) |
//Part 2. Chapter 13. Exercise 8
//------------------------------------------------------------------------------
struct Hexagon : Shape {
|
view (56 lines) |
//Part 2. Chapter 13. Exercise 6
//------------------------------------------------------------------------------
#define _USE_MATH_DEFINES // to use M_PI constanc (pi number)
|
view (112 lines) |
// new ver. of Arrow::Shape with fixed arrow size
//------------------------------------------------------------------------------
struct Arrow : Shape {
|
view (125 lines) |
// version of Box:Shape with circle-arcs
// previous version of Box have ellipse-arcs (that depend on major and minor axes)
//------------------------------------------------------------------------------
|
view (123 lines) |
//Part 2. Chapter 13. Exercise 2.
//------------------------------------------------------------------------------
struct Box : Shape {
|
view (116 lines) |
//Part 2. Chapter 13. Exercise 3.
//------------------------------------------------------------------------------
struct Arrow : Shape {
|
view (73 lines) |
//Part 2. Chapter 13. Exercise 5.
#include "Graph.h"
Point n(const Graph_lib::Rectangle& r) {
|
view (194 lines) |
// Part 2. Chapter 12. Exercize 13. incomlete
//------------------------------------------------------------------------------
#define _USE_MATH_DEFINES // to use M_PI constanc (pi number)
|
view (122 lines) |
// 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) |
// Part 2. Chapter 11. Excercize 4.
#include "../../std_lib_facilities.h"
int main() {
|
view (41 lines) |
// Part 2. Chapter 11. Excercize 3.
#include "../../std_lib_facilities.h"
int str_to_int(const string& s, string& base) {
|
view (56 lines) |
// Part 2. Chapter 11. Excercize 2.
#include "../../std_lib_facilities.h"
const vector<char>& get_vowel() {
static vector<char> vowel;
|
view (65 lines) |
// 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) |
// Part 2. Chapter 10. Excercize 12. use getline to get words from file
#include "../../std_lib_facilities.h"
int main ()
try {
|
view (30 lines) |
// 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) |
// 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) |
// 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) |
// Part 2. Chapter 10. Exercize 6. implement class Roman_int Roman.h
/*
1 I лат. unus
5 V лат. quinque
10 X лат. decem
|
view (407 lines) |
// 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) |
// 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) |
// 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) |
// 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) |
// Part 1. Chapter 9. Exercize 12. change represantation of Date class
// Chrono.h
#include "../../std_lib_facilities.h"
|
view (329 lines) |
// Part 1. Chapter 9. Exercise 13. Rational class
#include "../../std_lib_facilities.h"
class Rational {
public:
class Invalid{}; // exeptions
|
view (119 lines) |
// Part 1. Chapter 9. Exercise 14-15. class Money
#include "../../std_lib_facilities.h"
//--------------------------------------------------------------
namespace Money_operations {
//--------------------------------------------------------------
|
view (149 lines) |
// 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) |
// main.cpp
// Part 1. Chapter 9. Exercize 9-10. class Library
#include "Library.h"
int main ()
|
view (41 lines) |
// Library.h
#include "Book.h"
#include "Patron.h"
//---------------------------------------------------------------------
|
view (106 lines) |
// Patron.h
#include "../../std_lib_facilities.h"
//------------------------------------------------------------------------------
class Patron {
|
view (36 lines) |
// Book.h
#include "../../std_lib_facilities.h"
#include "Chrono.h"
using namespace Chrono;
class Book {
|
view (114 lines) |
// 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) |
// 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) |
// 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) |
// Part 1. Chapter 9. Exercize 2. implement class Name_pairs
#include "../../std_lib_facilities.h"
class Name_pairs {
|
view (94 lines) |
// 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) |
// 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) |
// 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) |
// 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) |
// 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) |
// 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) |
// 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) |
// Part 1. Chapter 8. Exercize 5. Swap vector elements order.
#include "../../std_lib_facilities.h"
void filling_vector(vector<int>& v)
{
|
view (49 lines) |
// 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) |
// Part 1. Chapter 8. Exersize 1.
#include "../../std_lib_facilities.h"
void print(vector<int>&, string&);
|
view (52 lines, 4 lines of output) |