- 1
http://www.bfilipek.com/2018/04/deprecating-pointers.html?m=1
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+3
http://www.bfilipek.com/2018/04/deprecating-pointers.html?m=1
Вот это удар в спину Царя! Он только начал нахваливать кресты,
как анскиллябры из комитета его предали.
0
https://twitter.com/jfbastien/status/979091653146193920
> 39 лойсов
> 13 ретвитов
Тьфу блять, хуже жаваскриптеров это крестушиное комьюнити.
+2
// We have to put a separate function with 'if constexpr' here as Visual Studio
// produces a false positive warning in a case of RegDstUInt == uint32
// (shifting uint32 left by 32 is an undefined behavior)
// See: https://developercommunity.visualstudio.com/content/problem/225040/c4293-false-positive-on-unreacheable-code.html
static RegDstUInt get_hi_part( RegDstUInt value)
{
// Clang-Tidy generates a false positive 'misc-suspicious-semicolon' warning
// on `if constexpr ()` with template
// LLVM bug 35824: https://bugs.llvm.org/show_bug.cgi?id=35824
if constexpr( (sizeof(RegDstUInt) > 4)
return value >> 32; // NOLINT
// GCC bug 81676 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81676
// Wrong warning with unused-but-set-parameter within 'if constexpr'
(void)(value);
return 0;
}
В попытке починить сборку в Visual Studio поломали GCC и Clang-Tidy.
+1
bool almostIncreasingSequence(std::vector<int> sq) {
bool b2 = true;
int s = sq.size();
if (s > 2) { // Последовательность меньше трех чисел дает истину.
int i = 1; // Проверка начинается со второго элемента.
int x = -1; // Для записи индекса элемента <= предыдущего, а еще "флаг".
while ((b2) && (i < s)) { // При нахождении 2-го лишнего происходит выход из цикла.
if (x != -1) { // Проверка "флага".
if (sq[i] <= sq[i - 1]){ // Сравнение с предыдущим элементом.
b2 = false; // Если условие истинно, то это уже второй элемент,
} // "конфликтующий" с предыдущим, следовательно, выход и "ложь".
if ((sq[i] <= sq[x - 1]) && (x != 1) && (sq[i - 1] <= sq[x - 2])) { // над этим условием я думал слишком долго
b2 = false; // Если элемент был "убран", индекс конфликтного
} // элемента записан в "x".
}
else { // Если условие ложно, то записываем индекс элемента, который
if (sq[i] <= sq[i - 1]) { // "конфликтует" с предыдущим.
x = i; // Нам не известно лишний он или нет.
}
}
i++;
}
}
return b2;
}
проверяет, можно ли убрать только один элемент из последовательности, чтобы она стала постоянно возрастающей.
+2
//Шапка таблицы
cout << setw(10) <<char(218) <<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(194)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(194)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(191) <<endl;
cout <<setw(10) <<char(179) <<setw(10) <<"X" <<setw(10) <<char(179) <<setw(10) <<"F" <<setw(10)
<<char(179) <<setw(10) <<"G" <<setw(10) <<char(179) <<endl;
for (i = 0; i <= N; i++) {
x = A + i*h;
F = (x-1)*(x-1)*(x-1);
G = ((x+5)*(x+5)*(x+5))/(1+(sin(x)*sin(x)));
//Вывод в таблицу
cout <<setw(10) << char(195)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(197)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(197)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(180)<<endl;
cout << setw(10) << char(179) << setw(10)<< x << setw(10) << char(179) << setw(10)<< setprecision(5) << F << setw(10) << char(179) << setw(10) << setprecision(6) << G << setw(10) << char(179) << endl;
} //for (i = 0; i <= N; i++)
//Конец таблицы
cout << setw(10) << char(192)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(193)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(193)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)<<char(196)
<<char(217)<<endl;
eto pizdez prosto, ya lettau blyad
0
class NTPTime {
public:
static NTPTime getInvalidTime() { NTPTime t; t.setInvalid(); return t; }
public:
NTPTime() : m_Time(0) {}
NTPTime(const uint64_t time) : m_Time(time) {}
NTPTime(const uint32_t sec, const uint32_t frac)
: m_Time(0)
{
this->set(sec, frac);
}
NTPTime(const boost::posix_time::ptime& timestamp);
public: // Assignment operators
NTPTime& operator=(const uint64_t u) { m_Time = u; return *this; }
NTPTime& operator+= (const NTPTime& Q) { m_Time += Q.m_Time; return *this; }
NTPTime& operator-= (const NTPTime& Q) { m_Time -= Q.m_Time; return *this; }
public: // Cast operators
operator uint64_t() { return this->m_Time; }
public: // comparison operators
bool operator==(const NTPTime& other) const { return (m_Time == other.m_Time); }
bool operator!=(const NTPTime& other) const { return (m_Time != other.m_Time); }
bool operator>=(const NTPTime& other) const { return (m_Time >= other.m_Time); }
bool operator>(const NTPTime& other) const { return (m_Time > other.m_Time); }
bool operator<=(const NTPTime& other) const { return (m_Time <= other.m_Time); }
bool operator<(const NTPTime& other) const { return (m_Time < other.m_Time); }
public: // arithmetic operators
NTPTime operator+(const NTPTime& other) const
{
NTPTime result = *this;
result += other;
return result;
}
NTPTime operator-(const NTPTime& other) const
{
NTPTime result = *this;
result -= other;
return result;
}
public:
uint32_t getSeconds() const { return ((uint32_t)(m_Time >> 32));}
uint32_t getFracSeconds() const { return ((uint32_t)(m_Time & 0xFFFFFFFF));}
uint32_t getMilliseconds() const { const uint64_t t = 1000*m_Time ; return (uint32_t)((t>>32)&0xFFFFFFFF);}
uint32_t getMicroseconds() const { const uint64_t t = 125*m_Time/536871; return (uint32_t)(t&0xFFFFFFFF);}
void getTime_s_us(uint32_t& sec, uint32_t& us) const { sec = getSeconds(); us = getFracSeconds()/4295;}
uint64_t getTime(void) const {return m_Time;}
public:
/// set the time in seconds and microseconds (micros: 0..1000 0000)
///This routine uses the factorization: 2^32/10^6 = 4096 + 256 - 1825/32
void setTime_s_us(const uint32_t sec, const uint32_t us) { m_Time = ((uint64_t)sec<<32) | ((us<<12)-((us*1852)>>5)+(us<<8));}
void set(const uint64_t& u) {m_Time = u;}
void set(const uint32_t sec, const uint32_t frac)
{
m_Time = sec;
m_Time = m_Time<<32;
m_Time |= frac;
}
void setInvalid() { m_Time = uint64_t(NOT_A_DATE_TIME) << 32; }
/// 2^32/10^6 = 4096 + 256 - 1825/32
void setMicroseconds(const uint32_t u) { const uint64_t t = ((uint64_t)u * 1825) >> 5; m_Time = ((uint64_t)u << 12) + ((uint64_t)u << 8) - t;}
void setMicroseconds(const uint64_t u) { const uint64_t t = (u * 1825) >> 5; m_Time = (u << 12) + (u << 8) - t;}
void setMilliseconds(const uint32_t u) { m_Time = (uint64_t)u * 536870912 / 125;}
void addMilliseconds(const uint32_t u) { NTPTime t; t.setMilliseconds(u); *this += t;}
void addMicroseconds(const uint32_t u) { NTPTime t; t.setMicroseconds(u); *this += t;}
protected:
static double round(const double v);
private:
static const double secondFractionNTPtoNanoseconds;
static const double nanosecondsToSecondFractionNTP;
static const uint32_t NOT_A_DATE_TIME;
static const uint64_t NOT_A_DATE_TIME64;
static const boost::posix_time::ptime m_epoch;
protected:
uint64_t m_Time; ///< NTP time in 1/2^32 seconds (~233 ps)
}; // NTPTime
Чуть г-на и несколько комментов удалил, чтоб влезло. Чтоб понятно было, m_Time хранит время в единицах 1/2^32 сек.
+1
// OK
class foo {};
void foo();
// не ОК: error: 'void bar()' redeclared as different kind of symbol
namespace bar {}
void bar();
"Двойные стандарты"
+4
template<class T, T = 1>
constexpr bool __can_one(int) { return true; };
template<class T>
constexpr bool __can_one(long) { return false; };
template <class T>
constexpr bool is_integral_v = __can_one<T>(0);
https://twitter.com/ericniebler/status/976524085927731200
Не кто попало, а автор Ranges TS (без пяти минут кусок стандарта) сомневается, валидную метушню он написал или нет. Пора уже создавать крестоблядский суд, который будет трактовать букву стандарта и решать, где с++ а где нет. И разрабы гцц будут нанимать за бешеное бабло крестоблядских юристов и судиться в крестоблядском суде с авторами багрепортов.
0
//Они относятся к посту ниже
#include "stdafx.h"
#include<iostream>
using namespace std;
/*Доказать что (АВ)^-1=B^-1*A^-1*/
void printLine(int n) {
n *= 2;
n--;
for (int i = 0; i < n;i++) {
cout << '*';
}
cout << endl;
}
void obr(bool **arr1,bool **arr2, int m, int n) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
arr2[i][j]=arr1[j][i];
//cout << arr1[j][i];
//cout << ' ';
}
//cout << endl;
}
}
void obr(bool **arr1, int m, int n) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << arr1[j][i];
cout << ' ';
}
cout << endl;
}
}
void multiple(bool **arr1, bool **arr2,bool **tempAr, int m, int n) {
for (int i = 0; i < m; i++) {
for (int j = 0;j < n; j++) {
tempAr[i][j]= arr1[i][j]* arr2[i][j];
cout << tempAr[i][j];
cout << ' ';
}
cout << endl;
}
}
void multiple(bool **arr1, bool **arr2, int m, int n) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cout << arr1[i][j] * arr2[i][j];
cout << ' ';
}
cout << endl;
}
}
void subtractionMatr(bool **arr1, bool **arr2, bool **tempAr, int m, int n) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if ((arr1[i][j] == true) && (arr2[i][j] == false)) {
tempAr[i][j] = true;
}
else {
tempAr[i][j] = false;
}
cout << tempAr[i][j];
cout << ' ';
}
cout << endl;
}
}
void subtractionMatr(bool **arr1, bool **arr2, int m, int n) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if ((arr1[i][j] == true) && (arr2[i][j] == false)) {
cout<< true;
}
else {
cout<< false;
}
cout << ' ';
}
cout << endl;
}
}
bool** setMemory(int m,int n) {
bool** ar;
ar = new bool*[m];
for (int i = 0; i < n; i++) {
ar[i] = new bool[n];
}
return ar;
}
void inputElements(bool **bar,int m,int n) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cin >> bar[i][j];
}
}
}
Код относящийся к посту ниже
+1
int main()
{
//Все функции в посте выше
int m,n;
bool **ar1;
bool **ar2,**ar3;
bool **tar;
bool **temp;
setlocale(LC_ALL, "RUS");
system("color F0");
cout << "\tЗАДАНИЕ 1" << endl;
cout << "Требуется доказать что (A*B)^-1=(B^-1)*(A^-1)" << endl;
cout << "Введите размерность матриц" << endl;
cin >> m;
cin >> n;
ar1 = setMemory(m, n);
ar2 = setMemory(m, n);
ar3 = setMemory(m, n);
tar = setMemory(m, n);
temp = setMemory(m, n);
cout << "Введите элементы матрицы А" << endl;
inputElements(ar1, m, n);
cout << "Введите элементы матрицы В" << endl;
inputElements(ar2, m, n);
cout << "Введите элементы матрицы C" << endl;
inputElements(ar3, m, n);
cout << "Cначала найдём (A*B)^-1" << endl;
cout << "A*B:" << endl;
multiple(ar1, ar2,tar, m, n);
cout << "Обратная (A*B): " << endl;
printLine(m);
obr(tar, m, n);
printLine(m);
cout << "Теперь переёдём к правой части, найдём (B^-1)*(A^-1) " << endl;
obr(ar2,tar, m, n);
obr(ar1, temp, m, n);
printLine(m);
multiple(tar, temp, m, n);
printLine(m);
cout << endl;
cout << endl;
printLine(40);
cout << "\tЗадание 2 " << endl;
cout << "Доказать что (А\\В)\\С=(А\\С)\\В " << endl;
cout << "А\\В :" << endl;
subtractionMatr(ar1, ar2, tar, m, n);
cout << "(А\\В)\\С :" << endl;
printLine(m);
subtractionMatr(tar, ar3, m, n);
printLine(m);
cout << "А\\C :" << endl;
subtractionMatr(ar1, ar3, tar, m, n);
cout << "(А\\C)\\B :" << endl;
printLine(m);
subtractionMatr(tar, ar2, m, n);
printLine(m);
system("pause");
return 0;
}