- 1
- 2
"Java", "Python" и "C/C++" - говно.
Факт.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−1
"Java", "Python" и "C/C++" - говно.
Факт.
+2
https://s22.postimg.cc/5zky9jn1t/Image_from_i_OS.jpg
0
https://habr.com/post/419141/
−3
#include <iostream>
using namespace std;
void wtf() {
return 0;
}
int main() {
return wtf();
cout << wtf();
}
Решил нопейсать ватафак-код.
Классика жанра. Ретурн в воидовской функции. Плюс действие после ретурна.
0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
/* The "Enter le ..." thing
is left for Шindows compilers.
Don't mind it. */
namespace SoloLearn
{
public class Program
{
public static void Main(string[] args)
{
int a = 0;
int b = 0; //Declare two numbers
string leChar; //Declare the character
int sum; //Declare the place where the result of the expression would be stored
Console.WriteLine("Enter le first number\n");
string c = a.ToString(); //Convert the 1st № to string
c = Console.ReadLine(); //Assign the 1st number
Console.WriteLine("Enter le character\n");
leChar = Console.ReadLine(); //Assign the char
Console.WriteLine("Enter le second number\n");
string d = b.ToString(); //Convert the 2nd № to string
d = Console.ReadLine(); //Assign the second number
a = System.Convert.ToInt16(c);
b = System.Convert.ToInt16(d);
sum = Calculate(a,leChar,b); //Calculate
Console.WriteLine("{0} {1} {2} is {3}", a, leChar, b, sum);
}
public static int Calculate(int x, string z, int y) {
int qwerty = 0;
switch(z) {
case "+": //Case of addition
qwerty = x + y;
break;
case "-": //Case of subtraction
qwerty = x - y;
break;
case "*": //Case of multiplication
qwerty = x * y;
break;
case "/": //Case of division
qwerty = x / y;
break;
}
return qwerty; //If smth = Calculate(parameters), var smth would have the content of this var © Your Captain Obvious
}
}
}
Выдавил из себя где-то месЕц назад. Как я умудрялся делать 2 переменные для просто стринговых версий существующих переменных только для того, чтобы прочитать инпут? Хорошо, что в сисярпе есть гарбаж коллектор. И да, названия переменных во второй функции - прекрасные (посмотрите: x, y, z, qwerty - не прекрасно ли?) говГо.
0
https://javascript.ru/forum/events/74655-peredacha-parametrov-v-funkciyu.html
https://javascript.ru/forum/events/74576-mozhno-li-ispolzovat-funkciyu-odnogo-diva-v-drugom.html
https://javascript.ru/forum/events/74553-kalkulyaciya-ceny-na-sajjte.html
−7
За "PHP"!
−2
<ul class="news-list">
<?php
global $news_list_toc;
foreach ($news_list_toc as $i => $d) {
echo <<<NI_ITEM
<li class="news-list-item">
<div class="news-list-item-date">
{$d['date']}
</div>
<div class="news-list-item-title">
<a href="?fetch=news&with=the&id={$i}">{$d['title']}</a>
</div>
</li>
NI_ITEM;
} ?>
</ul>
Нашел при рефакторинге своего проекта. Чем, чем я думал, когда писал это? У нормальных людей такого органа кажется и нету...
Показывать на собеседованиях с вопросом "что вам нравится в этом коде?"
0
https://www.youtube.com/watch?v=UcO6OXVZGyI
Можно промотать в конец.
0
#include <iostream>
#include <memory>
#include <thread>
#include <chrono>
#include <mutex>
struct Base
{
Base() { std::cout << " Base::Base()\n"; }
// Note: non-virtual destructor is OK here
~Base() { std::cout << " Base::~Base()\n"; }
};
struct Derived: public Base
{
Derived() { std::cout << " Derived::Derived()\n"; }
~Derived() { std::cout << " Derived::~Derived()\n"; }
};
void thr(std::shared_ptr<Base> p)
{
std::this_thread::sleep_for(std::chrono::seconds(1));
std::shared_ptr<Base> lp = p; // thread-safe, even though the
// shared use_count is incremented
{
static std::mutex io_mutex;
std::lock_guard<std::mutex> lk(io_mutex);
std::cout << "local pointer in a thread:\n"
<< " lp.get() = " << lp.get()
<< ", lp.use_count() = " << lp.use_count() << '\n';
}
}
int main()
{
std::shared_ptr<Base> p = std::make_shared<Derived>();
std::cout << "Created a shared Derived (as a pointer to Base)\n"
<< " p.get() = " << p.get()
<< ", p.use_count() = " << p.use_count() << '\n';
std::thread t1(thr, p), t2(thr, p), t3(thr, p);
p.reset(); // release ownership from main
std::cout << "Shared ownership between 3 threads and released\n"
<< "ownership from main:\n"
<< " p.get() = " << p.get()
<< ", p.use_count() = " << p.use_count() << '\n';
t1.join(); t2.join(); t3.join();
std::cout << "All threads completed, the last one deleted Derived\n";
}
https://en.cppreference.com/w/cpp/memory/shared_ptr
Объясните почему "reset" не грохнул инстанс в других потоках?