- 1
https://phpclub.ru/talk/threads/перевод-алгаритма-с-1с-в-пхп.52808/
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
https://phpclub.ru/talk/threads/перевод-алгаритма-с-1с-в-пхп.52808/
+2
gr = love.graphics
win = love.window
lk = love.keyboard
require("button")
require("t")
function love.load()
local loading = {}
loading = serialize.load("records.lua")
font = gr.newFont("NotoSans.ttf",14)
mini = gr.newFont("NotoSans.ttf",10)
big = gr.newFont("NotoSans.ttf",30)
flag = nil --Flag = nil -menu, Flag = 1 -records, Flag = 2 -type game, Flag = 3 -type game standart, Flag = 4 -type game impulse, Flag = 5 -type game Invers, Flag = 6 -type game Unreal
kube = {x = 96, y = 196, colx = 8, coly = 8}
speed = 1
timer = 0
umber = {}
records = {{"Standart", 0},{"Impulse", 0},{"Invers", 0},{"Unreal", 0},{"XY diagonal", 0},{"Perpendiculars", 0}}
if loading and #loading > 0 then
for i = 1, #loading do
records[i][2] = loading[i]
end
end
score = 0
mb = {utton:create(200-font:getWidth(">Play<")/2,125,">Play<"),utton:create(200-font:getWidth(">Records<")/2,160,">Records<"),utton:create(200-font:getWidth(">Exit<")/2,195,">Exit<")}
tgb = {utton:create(200-font:getWidth(">Standart<")/2,60,">Standart<"),utton:create(200-font:getWidth(">Impulse<")/2,90,">Impulse<"),utton:create(200-font:getWidth(">Invers<")/2,120,">Invers<"),utton:create(200-font:getWidth(">Unreal<")/2,150,">Unreal<"),utton:create(200-font:getWidth(">XY diagonal<")/2,180,">XY diagonal<"),utton:create(200-font:getWidth(">Perpendiculars<")/2,210,">Perpendiculars<")}
back = utton:create(200-font:getWidth(" >Back< ")/2,300," >Back< ")
r = utton:create(200-font:getWidth(" >Restart< ")/2,250," >Restart< ")
end
local function restart()
kube = {x = 96, y = 196, colx = 8, coly = 8, speed = 350}
speed = 1
timer = 0
umber = {}
score = 0
toch = nil
end
My первый игра сделаная на love2d. Аж всплакнул.
−1
ЧисловойСимвол = ?(Найти("0123456789",СимволVIN)>0,Истина,Ложь);
Проверка на то, является ли "СимволVIN" числом
+3
using System;
// Интерфейс места содержит координату его расположения
interface IPlace { long Distance { get; } }
// Интерфейс "двигатель" имеет его мощность
interface IEngine { float Power { get; } }
// Интерфейс Транспорт содержит двигатель и функция расчета времени на путь к определенному месту
interface IVehicle { IEngine Engine { get; } float TimeToTrip(IPlace place); }
// Интерфейс человека, имеющего дом и какой-либо транспорт
interface IPerson { IPlace Home { get; } IVehicle Vehicle { get; } }
// Описываем некоторые классы, реализующие интерфейс места
class Home : IPlace { public long Distance => 0; } // Класс дома, расположенного в начале координат
class Work : IPlace { public long Distance => 100; } // Класс рабочего офиса и расстояние до него
class School : IPlace { public long Distance => 58; } // Класс школы. Она расположена ближе к началу
// Петя -- это рабочий человек, ездящий на работу на автомобиле
class Petya : IEngine, IVehicle, IPerson
{
IVehicle car; // автомобиль
IEngine engine; // двигатель внешнего сгорания
IPlace home; // Петин дом
public float Power => 80f; // максимальная мощность двс в км/ч
public IEngine Engine => engine; // возвращаем двигатель авто
public IPlace Home => home; // возвращаем Петин дом
public IVehicle Vehicle => car; // возвращаем авто как транспорт
// Рассчитываем время, требуемое на путь
public float TimeToTrip(long distance) => distance / Engine.Power;
public float TimeToTrip(IPlace place) => TimeToTrip(place.Distance - home.Distance);
// Конструктор Пети, принимающий транспорт и его двигатель
public Petya(IEngine engine, IVehicle vehicle)
{ car = vehicle; this.engine = engine; }
// Конструктор, задающий Петин дом
public Petya(IPlace place = null)
{ // Если дома нет, создаем его сами
home = place ?? new Home();
car = this; engine = this;
}
}
// Иван -- школьник, он ездит в школу на велосипеде
class Ivan : IEngine, IVehicle, IPerson
{
IVehicle bike; // Ваня ездит на велосипеде
IEngine legs; // в качестве двигателя выступают Ванины ноги
IPlace home; // дом Вани
public float Power => 15f; //максимальная скорость Ваниных ног в к/мч
public IEngine Engine => legs; // возвращаем ноги в виде двигателя
public IPlace Home => home; // возвращаем Ванин дом
public IVehicle Vehicle => bike; // возвращаем велосипед как транспорт
// Рассчитываем время, требуемое на путь
public float TimeToTrip(long distance) => distance / Engine.Power;
public float TimeToTrip(IPlace place) => TimeToTrip(place.Distance - home.Distance);
// Конструктор Вани, принимающий транспорт и его двигатель
public Ivan(IEngine engine, IVehicle vehicle)
{ bike = vehicle; legs = engine; }
// Конструктор, задающий Ванин дом
public Ivan(IPlace place = null)
{ // Если дома нет, создаем его сами
home = place ?? new Home();
bike = this; legs = this;
}
}
class InterfacesLesson
{
// Вспомогательный метод для вывода на экран нужной нам информации
static void PrintInfo(IPerson person, IPlace place)
{
Console.WriteLine("{0} едет из {1} в {2} за {3:f2} ч.",
person, person.Home, place, person.Vehicle.TimeToTrip(place));
}
static void Main()
{
IPlace // Создаем несколько мест
home = new Home(),
work = new Work(),
school = new School();
IPerson // Создаем несколько людей
petya = new Petya(),
ivan = new Ivan(),
egor = new Ivan(school);
// Проверяем, кто за какое время добирается к нужному месту
PrintInfo(petya, home);
PrintInfo(petya, work);
PrintInfo(ivan, school);
PrintInfo(egor, work);
PrintInfo(egor, home);
Console.ReadLine();
}
}
Вот таким примером учат в одном известном ВУЗе интерфейсам...
+2
https://i.yapx.ru/D3IPu.jpg
Как я вам?)
+2
Если ЭтоКонецПрихода = 1 Тогда
ЭтоКонецПрихода = ЭтоКонецПрихода+1;
1. Реальный код
2. Переменная используется как логическая, 0 и 1
+2
#include <stdio.h>
#include <math.h>
#define SET(var, ...) typeof(__VA_ARGS__) var = __VA_ARGS__
SET(p, &puts);
struct point_t { double x, y; };
SET(point, (struct point_t){0.0, 1.0});
SET(anonymous, (struct{char *s;}){"hui"});
int main(void)
{
static SET(msg, "Halo!");
p(msg);
SET(sqrt_of_2, sqrt(2));
printf("√2 = %f\n", sqrt_of_2);
return 0;
}
Автовывод типов в "C".
+1
https://habr.com/ru/sandbox/127860/
−5
Перепись долбоёбов.
Отписываемся в комментах.
0
// AFJSONRPCClient.m
//
// Created by [email protected]
// Copyright (c) 2013 JustCommunication
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "AFHTTPRequestOperationManager.h"
/**
AFJSONRPCClient objects communicate with web services using the JSON-RPC 2.0 protocol.
@see http://www.jsonrpc.org/specification
*/
@interface AFJSONRPCClient : AFHTTPRequestOperationManager
/**
The endpoint URL for the webservice.
*/
@property (readonly, nonatomic, strong) NSURL *endpointURL;
/**
Creates and initializes a JSON-RPC client with the specified endpoint.
@param URL The endpoint URL.
@return An initialized JSON-RPC client.
*/
+ (instancetype)clientWithEndpointURL:(NSURL *)URL;
/**
Initializes a JSON-RPC client with the specified endpoint.
@param URL The endpoint URL.
@return An initialized JSON-RPC client.
*/
- (id)initWithEndpointURL:(NSURL *)URL;
/**
Creates a request with the specified HTTP method, parameters, and request ID.
@param method The HTTP method. Must not be `nil`.
@param parameters The parameters to encode into the request. Must be either an `NSDictionary` or `NSArray`.
@param requestId The ID of the request.
@return A JSON-RPC-encoded request.
*/
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
parameters:(id)parameters
requestId:(id)requestId;
/**
Creates a request with the specified method, and enqueues a request operation for it.
@param method The HTTP method. Must not be `nil`.
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer.
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred.
*/
- (void)invokeMethod:(NSString *)method
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
/**
Creates a request with the specified method and parameters, and enqueues a request operation for it.
@param method The HTTP method. Must not be `nil`.
@param parameters The parameters to encode into the request. Must be either an `NSDictionary` or `NSArray`.
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer.
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred.
*/
- (void)invokeMethod:(NSString *)method
withParameters:(id)parameters
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;
/**
Creates a request with the specified method and parameters, and enqueues a request operation for it.
@param method The HTTP method. Must not be `nil`.
@param parameters The parameters to encode into the request. Must be either an `NSDictionary` or `NSArray`.
@param requestId The ID of the request.
@param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer.
@param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred.
*/
- (void)invokeMethod:(NSString *)method