This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Implement atoi which converts a string to an integer. | |
The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. | |
The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. | |
If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed. | |
If no valid conversion could be performed, a zero value is returned. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Given an input string, reverse the string word by word. | |
Example: | |
Input: "the sky is blue", | |
Output: "blue is sky the". | |
Note: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
based on: "A shortcut for wrapping Objective-C objects in C++" | |
http://philjordan.eu/article/mixing-objective-c-c++-and-objective-c++ | |
don't forget to turn off ARC: | |
You can disable ARC for individual files in XCode under the 'Build Phases' tab in the build target's properties. | |
Fold out the 'Compile Sources' section and add `-fno-objc-arc` to the compiler flags for the file(s) in question. | |
for MyObject.mm (`-fno-objc-arc`) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <memory> | |
#include <algorithm> | |
class DataObject { | |
public: | |
DataObject(std::string_view value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
// Example from Jason Turner's video. | |
// https://youtu.be/JtUZmkvroKg?t=290 | |
void print(int i, const std::string_view s) { | |
std::cout << i << ' ' << s << '\n'; | |
} | |
int main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
// Example from Jason Turner's video. | |
// https://youtu.be/JtUZmkvroKg?t=290 | |
template <typename T> | |
void print(T i, const std::string_view s) { | |
std::cout << i << ' ' << s << '\n'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Learning C++ Best Practices :: Avoid Defining Any Default Operations, Or Define Them All (Jason Turner) | |
* https://learning.oreilly.com/videos/learning-c-best/9781491954898/9781491954898-video241545 | |
*/ | |
#include <string> | |
struct S { | |
~S() {}; | |
std::string s; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RandomStringUtils { | |
private static final SecureRandom RANDOM = new SecureRandom(); | |
private static final String cyrillicCharacters = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"; | |
public static String generateRandomCharacter(){ | |
int randomCharIndex = RANDOM.nextInt(cyrillicCharacters.length()); | |
return String.valueOf(cyrillicCharacters.charAt(randomCharIndex)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.1' | |
services: | |
zookeeper: | |
image: confluentinc/cp-zookeeper:latest | |
environment: | |
- ZOOKEEPER_CLIENT_PORT=2181 | |
- ZOOKEEPER_TICK_TIME=2000 | |
ports: | |
- "32181:2181" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Приложение: Менеджер карт | |
У Клиента есть набор различных карт (дебетовые, кредитные, скидочные) различных банков. | |
Каждая карта имеет номер, тип, дату истечения (месяц и год). | |
Номер карты представлен 20 символьной цифровой последовательностью. | |
Имя банка или магазина определяется первыми 4 символами номера. | |
Реализовать функциональность работы с картами клиента (добавление/удаление), | |
вывод списка клиентов и информацию о количестве его карт (с сортировкой по имени клиента) | |
вывод в консоль информацию в удобно читаемом виде по всем картам у конкретного клиента (в порядке убывания количества карт у клиента) |