это не стек, а linked liststruct stack { int data; stack* next; };
это не стек, а linked liststruct stack { int data; stack* next; };
Что это за треш, думаю не стоит приводить в пример такую ебанутую реализациючтобы не мучать голову со своим классом стака(если не требуется создавать его самому) - то используй std::stackstack imp:#include <bits/stdc++.h> using namespace std; #define MAX 10 class Stack { int top; public: int a[MAX]; Stack() { top = -1; } bool push(int x); int pop(); int peek(); bool isEmpty(); }; bool Stack::push(int x) { if (top >= (MAX - 1)) { return false; } else { a[++top] = x; cout << "push " << x << "\n"; return true; } } int Stack::pop() { if (top < 0) { return 0; } else { int x = a[top--]; return x; } } int Stack::peek() { if (top < 0) { return 0; } else { int x = a[top]; return x; } } bool Stack::isEmpty() { return (top < 0); } int main() { class Stack stackInst; // заполняем стак for(size_t i = 0; i < MAX; i++) { stackInst.push(i); } // избавляемся от четных элементов стака class Stack stackBuffer; while (!stackInst.isEmpty()) { int val = stackInst.peek(); stackInst.pop(); if (val % 2 == 1) stackBuffer.push(val); } while (!stackBuffer.isEmpty()) { stackInst.push(stackBuffer.peek()); stackBuffer.pop(); } // стак на выходе cout << "current stack data: "; while(!stackInst.isEmpty()) { cout<<stackInst.peek()<<" "; stackInst.pop(); } return 0; } /* output: push 0 push 1 push 2 push 3 push 4 push 5 push 6 push 7 push 8 push 9 push 9 push 7 push 5 push 3 push 1 push 1 push 3 push 5 push 7 push 9 current stack data: 9 7 5 3 1 */
я ниже писал про современный методЧто это за треш, думаю не стоит приводить в пример такую ебанутую реализацию
#include <iostream>
#include <stack>
const int CONST_MAX_SIZE = 10;
int main() {
std::stack<int> stackInst;
std::stack<int> stackBuffer;
for (size_t i = 0; i < CONST_MAX_SIZE; i++) {
stackInst.push(i);
}
while (!stackInst.empty()) {
int topValue = stackInst.top();
stackInst.pop();
if (topValue % 2 == 1) {
stackBuffer.push(topValue);
}
}
while (!stackBuffer.empty()) {
stackInst.push(stackBuffer.top());
stackBuffer.pop();
}
std::cout << "current stack data: ";
while (!stackInst.empty()) {
std::cout << stackInst.top() << " ";
stackInst.pop();
}
return 0;
}
Если тебе нужно включить отображение ников через стены, то нужно ставить falseЯ не понимаю как использовать sampapi, пожалуйста кто шарит за этот кал покажите будет выглядеть готовое решение, чтобы понять как с этим работать
C:[/B] { Sleep(1); } sampapi::v037r3::RefNetGame()->m_pSettings->m_bNoNametagsBehindWalls = true ; }
если SAMP API это кал, зачем его юзать?этот кал
Нет другого апиесли SAMP API это кал, зачем его юзать?
Вы можете исправить код ?Если тебе нужно включить отображение ников через стены, то нужно ставить false
Если ты не умеешь водить на механике, а только на автомате - это ты тупой, а не МКППэтот кал
зач ты оффтопишь если знаешь помоги, объясни, покажи как нужноЕсли ты не умеешь водить на механике, а только на автомате - это ты тупой, а не МКПП
Затем что ты придурок.если SAMP API это кал, зачем его юзать?
Нахера ты юзаешь sleep? Кидай весь код нам. Поможем.Я не понимаю как использовать sampapi, пожалуйста кто шарит за этот кал покажите будет выглядеть готовое решение, чтобы понять как с этим работать
C:[/B] { Sleep(1); } sampapi::v037r3::RefNetGame()->m_pSettings->m_bNoNametagsBehindWalls = true ; }
Да там обычный тест код пару строк, я не понимаю как работать с функциями из этого апи, в целом я неправильно начал функции и при компиляции ошибка, думаю чел который шарит поймет что я не правильно сделал, не обессудь просто хочу научится.Затем что ты придурок.
Нахера ты юзаешь sleep? Кидай весь код нам. Поможем.
[/B]
#include "main.h"
void __cdecl DLLProject(void* pArg)
{
while (true)
{
Sleep(1);
if (GetAsyncKeyState(VK_END))
{
while (GetAsyncKeyState(VK_END))
{
Sleep(1);
}
sampapi::v037r3::RefNetGame()->m_pSettings->m_bNoNametagsBehindWalls = false;
}
}
}
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ PVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH) _beginthread(DLLProject, NULL, nullptr);
return TRUE;
}
#include <Windows.h>
#include "main.h"
SAMPFUNCS *SF = new SAMPFUNCS();
bool test = false;
#define color_red "AA3333"
#define color_green "33AA33"
void CALLBACK hMenu(std::string param)
{
char outMenu[9];
sprintf(outMenu, "{%s}test",
test ? color_green : color_red);
if (param == "1")
SF->getSAMP()->getChat()->AddChatMessage(-1, "фаст выбор тест");
else
return SF->getSAMP()->getDialog()->ShowDialog(8521, 2, "Title test", outMenu, "Выбрать", "Закрыть");
};
void __stdcall mainloop()
{
static bool initialized = false;
if (!initialized)
{
if (GAME && GAME->GetSystemState() == eSystemState::GS_PLAYING_GAME && SF->getSAMP()->IsInitialized())
{
SF->getSAMP()->getChat()->AddChatMessage(-1, "Debug: {008000}SUCCESS");
SF->getSAMP()->registerChatCommand("cout", hMenu);
initialized = true;
}
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
if (dwReasonForCall == DLL_PROCESS_ATTACH)
SF->initPlugin(mainloop, hModule);
return TRUE;
}
ставить хук на диалогSF. Как отлавливать, нажатие кнопок и какой пункт выбран?
C++:#include <Windows.h> #include "main.h" SAMPFUNCS *SF = new SAMPFUNCS(); bool test = false; #define color_red "AA3333" #define color_green "33AA33" void CALLBACK hMenu(std::string param) { char outMenu[9]; sprintf(outMenu, "{%s}test", test ? color_green : color_red); if (param == "1") SF->getSAMP()->getChat()->AddChatMessage(-1, "фаст выбор тест"); else return SF->getSAMP()->getDialog()->ShowDialog(8521, 2, "Title test", outMenu, "Выбрать", "Закрыть"); }; void __stdcall mainloop() { static bool initialized = false; if (!initialized) { if (GAME && GAME->GetSystemState() == eSystemState::GS_PLAYING_GAME && SF->getSAMP()->IsInitialized()) { SF->getSAMP()->getChat()->AddChatMessage(-1, "Debug: {008000}SUCCESS"); SF->getSAMP()->registerChatCommand("cout", hMenu); initialized = true; } } } BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved) { if (dwReasonForCall == DLL_PROCESS_ATTACH) SF->initPlugin(mainloop, hModule); return TRUE; }
Можешь объяснить как?ставить хук на диалог
-- while true do
local result, button, list, input = sampHasDialogRespond(3333)
if result then
if button == 1 then
if list == 0 then
-- code
end
end
end
Так же как и на серверный диалог, на вики есть пример на SFМожешь объяснить как?
Просто это локальный диалог и в том же Lua можно было обойтись вот так:
Lua:-- while true do local result, button, list, input = sampHasDialogRespond(3333) if result then if button == 1 then if list == 0 then -- code end end end