+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
for(int b = 0; b < len; b++){
resultByte[b] = (byte)(buf[b] & 0xFF);
crc32 ^= (buf[b] << 24);
if(crc32 < 0) {crc32 = (crc32 << 1) ^ POLYNOMIAL;} else {crc32 = crc32 << 1;}
if(crc32 < 0) {crc32 = (crc32 << 1) ^ POLYNOMIAL;} else {crc32 = crc32 << 1;}
if(crc32 < 0) {crc32 = (crc32 << 1) ^ POLYNOMIAL;} else {crc32 = crc32 << 1;}
if(crc32 < 0) {crc32 = (crc32 << 1) ^ POLYNOMIAL;} else {crc32 = crc32 << 1;}
if(crc32 < 0) {crc32 = (crc32 << 1) ^ POLYNOMIAL;} else {crc32 = crc32 << 1;}
if(crc32 < 0) {crc32 = (crc32 << 1) ^ POLYNOMIAL;} else {crc32 = crc32 << 1;}
if(crc32 < 0) {crc32 = (crc32 << 1) ^ POLYNOMIAL;} else {crc32 = crc32 << 1;}
if(crc32 < 0) {crc32 = (crc32 << 1) ^ POLYNOMIAL;} else {crc32 = crc32 << 1;}
}
resultByte[len+3] = (byte)(crc32 & 0xFF);
resultByte[len+2] = (byte)((crc32 >>> 8) & 0xFF);
resultByte[len+1] = (byte)((crc32 >>> 16) & 0xFF);
resultByte[len] = (byte)((crc32 >>> 24) & 0xFF);
MininN,
10 Сентября 2018
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
/* Get LDAC handle */
LDACBT_API HANDLE_LDAC_BT ldacBT_get_handle( void )
/* Free LDAC handle */
LDACBT_API void ldacBT_free_handle( HANDLE_LDAC_BT hLdacBT )
/* Close LDAC handle */
LDACBT_API void ldacBT_close_handle( HANDLE_LDAC_BT hLdacBT )
/* Get ERROR CODE */
LDACBT_API int ldacBT_get_error_code( HANDLE_LDAC_BT hLdacBT )
/* Get Configured Sampling frequency */
LDACBT_API int ldacBT_get_sampling_freq( HANDLE_LDAC_BT hLdacBT )
СОНЭ умеет в комментарии.
https://android.googlesource.com/platform/external/libldac/+/master/src/ldacBT_api.c
Elvenfighter,
09 Сентября 2018
+1
- 1
- 2
- 3
https://pbs.twimg.com/media/Dl4x_P-XsAAPfgC.jpg
https://twitter.com/_inside/status/1035319938641276928 The Apple Watch pride face is hardcoded to not show up if the paired iPhone is using the Russian locale
> Однако 30 октября 2014 года в статье на Bloomberg Businessweek Кук совершил каминг-аут, признавшись в своей гомосексуальности, и выразил надежду, что это признание поможет другим геям принять себя и вдохновит их на борьбу за свои права.
Бабло победило принципы
j123123,
05 Сентября 2018
+1
#
## #### #### ##### ######
# # # # # # # #
# # #### # # #####
# ### # # ##### #
# ### # # # # # # #
##### ### #### #### # # #
# # ###### ##### # ###### # #### ## ##### # #### # #
# # # # # # # # # # # # # # # # ## #
# # ##### # # # ##### # # # # # # # # # # #
# # # ##### # # # # ###### # # # # # # #
# # # # # # # # # # # # # # # # # ##
## ###### # # # # # #### # # # # #### # #
###### ##### ##### #### #####
# # # # # # # # #
##### # # # # # # # #
# ##### ##### # # #####
# # # # # # # # #
###### # # # # #### # #
Konardyan,
05 Сентября 2018
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
class TaxStorage {
public:
using TaxCode = Code<3>; // Code<int N, typename Storage = uint32_t> тип для маленьких строк
using TaxType = Code<3>;
using TaxId = std::tuple<TaxCode, TaxType>;
using TaxMap = std::map<TaxId, int>
using CityId = int;
using TaxPointMap = std::unordered_map<CityId, TaxMap>;
TaxMap forCityOrOther(const TaxPointMap& map, const CityId cityId) const {
const auto found = map.find(cityId);
return found == map.cend() ? map.at(OTHER_CITY) : *found; // должно быть found->second
}
}
Dev: Ok GCC, tell me what is wrong.
GCC: /home/whatever/project/TaxStorage.h:102: error: incompatible operand types ('const std::unordered_map<int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > >, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<const int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > > > > >::mapped_type' (aka 'const std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > >') and 'const std::pair<const int, std::map<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> >, std::less<std::tuple<Code<3, unsigned int>, Code<3, unsigned int> > >, std::allocator<std::pair<const std::tuple<Code<3, unsigned int>, Code<3, unsigned int> >, std::vector<unsigned long, std::allocator<unsigned long> > > > > >')
ДОКОЛЕ?!!
Elvenfighter,
24 Августа 2018
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
#include <iostream>
#include <type_traits>
#include <utility>
#include <array>
template<size_t Size, typename T, typename FunctorType, size_t... idx>
constexpr std::array<decltype(std::declval<FunctorType>().operator()(std::declval<T>())), Size>
map_impl(const std::array<T, Size> & arr, FunctorType && f, std::index_sequence<idx...>)
{
return std::array{ f(std::get<idx>(arr))... };
}
template<size_t Size, typename T, typename FunctorType>
constexpr std::array<decltype(std::declval<FunctorType>().operator()(std::declval<T>())), Size>
map(const std::array<T, Size> & arr, FunctorType && f)
{
return map_impl(arr, f, std::make_index_sequence<Size>{});
}
struct MyFunctor {
constexpr float operator()(int arg)
{
return static_cast<float>(arg * arg) / 2.0f;
}
};
int main()
{
constexpr std::array arr{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
auto arrMappedFunctor = map(arr, MyFunctor{});
auto arrMappedLambda = map(arr, [](int x) constexpr { return static_cast<float>(x * x) / 2.0f; });
for (auto && x : arrMappedFunctor) {
std::cout << x << ' ';
}
std::cout << std::endl;
for (auto && x : arrMappedLambda ) {
std::cout << x << ' ';
}
std::cout << std::endl;
return 0;
}
0.5 2 4.5 8 12.5 18 24.5 32 40.5 50
0.5 2 4.5 8 12.5 18 24.5 32 40.5 50
Метушня выходит на новый уровень: полноценный map в compile-time. Поддерживает как ручные функторы с перегруженным operator(), так и constexpr-лямбды. При помощи небольшой модификации возможно реализовать поддержку кортежей с произвольными типами.
gost,
18 Августа 2018
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#define next ;
#define zero 0
#define one 1
#define two 2
#define three 3
#define four 4
#define five 5
#define six 6
#define seven 7
#define eight 8
#define nine 9
#define dot .
#define begin {
#define end }
#define open (
#define close )
#define sqopen [
#define sqclose ]
#define less <=
#define xless <
#define greater >=
#define xgreater >
#define isnt !=
#define isequal ==
#define mustbe =
#define write cout
#define plus +
#define minus -
#define multi *
#define divby /
#define incr +=
#define decr -=
using namespace std next
string pswdGen open int quantity close begin
srand open time open 0 close close next
char chars sqopen sqclose mustbe "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890@\#\$\%\&\-\+\!\/\_" next
string password next
for(int i = zero next i xless quantity next i++) begin
password incr chars sqopen rand open close % open sizeof open chars close divby sizeof open *chars close close sqclose next
end
return password next
end
int main open close begin
int charNo next
write << "How many characters do you want in the password?" << endl next
cin >> charNo next
write << "Your new password is: " << pswdGen open charNo close << endl next
return zero next
end
По сути это тот же крестовый паролегенератор, но из-за дефайнов и от того символов можно отнести в кучу. И да, "Переведи на "зрз"" в сторону. Перевел вам за щеку, проверяйте
shite,
08 Августа 2018
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
let suffix = '';
if (search) {
if (filters.length) {
suffix = ' found:';
} else {
suffix = ' found';
}
} else {
if (filters.length) {
suffix = ' found:';
}
}
Когда не уверен, нужно двоеточие или нет.
b4lk0n,
07 Августа 2018
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
// NextViewController.swift
override func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
NSUserDefaults.standardUserDefaults().setInteger(indexPath.row, forKey: "Selected offense")
let offense: NSDictionary = self.offenses.objectAtIndex(indexPath.row) as NSDictionary
let id: Int = offense.objectForKey("id") as Int
let title: String = offense.objectForKey("title") as String
NSUserDefaults.standardUserDefaults().setInteger(id, forKey: "Selected offense id")
NSUserDefaults.standardUserDefaults().setObject(title, forKey: "Selected offense title")
}
// PreviousViewController.swift
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
hideKeyboard()
tableView.reloadData()
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let kCellIndetifier: String = "NewOffenseCell"
var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIndetifier, forIndexPath: indexPath) as UITableViewCell
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: kCellIndetifier)
}
cell.text = NSUserDefaults.standardUserDefaults().stringForKey("Selected offense title")
cell.font = UIFont.systemFontOfSize(20)
return cell
}
Реализуем колбэки *лицорука*
def,
06 Августа 2018