Подпишитесь на наш Telegram-канал, чтобы всегда быть в курсе важных обновлений! Перейти

Софт Random words generator

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
22 Окт 2022
Сообщения
101
Реакции
24
1.2. Запрещено выделять всё сообщение жирным шрифтом, курсивом, подчеркиванием, цветом. Пользуйтесь BB-кодами с умом, выделяя лишь самое важное в теме, на что следует обратить внимание.
Что это? / What this?
Ru: Это софт который может случайным образом сгенерировать слова которые указаны в файле words или без него(не понимаю для чего делали),хуета написанная на C++
Eng: This is software that can randomly generate words that are specified in the words file or without it (I don't understand why they did it), the fuck is written in C++

Инструкция / Instruction
Ru: Разархивируйте или скомпилируйте софт, создайте файл words.txt (может работать и без него но генерит полный пиздец)
Eng: Unzip the archive or compile the software create a file words.txt (it can work without it, but it will be completely fucked up)

Download and VT
Пожалуйста, авторизуйтесь для просмотра ссылки.
- (нн антивирусы жалуются)
rat.
Пожалуйста, авторизуйтесь для просмотра ссылки.

backdoor.
Пожалуйста, авторизуйтесь для просмотра ссылки.

Пожалуйста, авторизуйтесь для просмотра ссылки.
credits: llama
 
Я согласен, но это ctrl+c ctrl+v из какого-то старого проекта
Не знаю зачем но я это написал, не тестировал, но на godbolt работает
Bad code!:
Expand Collapse Copy
#include <fstream>
#include <iostream>
#include <random>
#include <vector>

// Define the file name
constexpr std::string_view svFileName { "Words.txt" };

// Check if the file name is empty (compile time)
static_assert( !svFileName.empty( ), "The file name cannot be empty!" );

template < class TValueType = std::uint32_t >
    requires std::integral< TValueType >
[[nodiscard]] constexpr TValueType GetRandomNumber( const TValueType &rMin, const TValueType &rMax ) noexcept {
    // Create a random engine
    std::mt19937_64 mtEngine { std::random_device { }( ) };

    // Create a uniform distribution between rMin and rMax
    std::uniform_int_distribution< TValueType > uidDistribution { rMin, rMax };

    // Return the random number
    return uidDistribution( mtEngine );
}

int main( ) try {
    // Open the file for reading
    std::ifstream ifsFile { svFileName.data( ), std::ios::in };

    // Check if the file is open
    if ( !ifsFile.is_open( ) )
        throw std::runtime_error { "The file cannot be opened!" };

    // Create a vector of words
    std::vector< std::string_view > vecWords { };

    // Read the words from the file
    for ( std::string strWord { }; std::getline( ifsFile, strWord ); )
        vecWords.emplace_back( strWord.data( ) );

    // Check if the vector is empty
    if ( vecWords.empty( ) )
        throw std::runtime_error { "The vector cannot be empty!" };

    // Get a random number
    const auto iRandomNumber { GetRandomNumber< std::uint32_t >( 0, vecWords.size( ) - 1 ) };

    // Print the random word
    std::cout << "Random word: " << vecWords.at( iRandomNumber ) << "\n";

    // Wait for the user to press a key (so that stop console)
    std::cin.get( );

    // Return false to indicate that the program ended successfully
    return 0;
} catch ( const std::exception &rException ) {
    // Print the exception message
    std::cout << "Exception: " << rException.what( ) << "\n";

    // Wait for the user to press a key (so that stop console)
    std::cin.get( );

    // Return true to indicate that the program ended with an error
    return 1;
}
 
Последнее редактирование:
Оно просто берёт из списка рандомное слово и выводит в консоль? Тогда почему генератор? Чево...
 
Оно просто берёт из списка рандомное слово и выводит в консоль? Тогда почему генератор? Чево...
Это генератор говна, каждый кто хочет щитпостить, может просто зайти в эту прогу.
 
Ну не знаю, пельмешка и без этого справлялся
3KdTgdv.png
tiv4r7f.png

Мы тоже броу
 
Что это? / What this?
Ru: Это софт который может случайным образом сгенерировать слова которые указаны в файле words или без него(не понимаю для чего делали),хуета написанная на C++
Eng: This is software that can randomly generate words that are specified in the words file or without it (I don't understand why they did it), the fuck is written in C++

Инструкция / Instruction
Ru: Разархивируйте или скомпилируйте софт, создайте файл words.txt (может работать и без него но генерит полный пиздец)
Eng: Unzip the archive or compile the software create a file words.txt (it can work without it, but it will be completely fucked up)

Download and VT
Пожалуйста, авторизуйтесь для просмотра ссылки.
- (нн антивирусы жалуются)
rat.
Пожалуйста, авторизуйтесь для просмотра ссылки.

backdoor.
Пожалуйста, авторизуйтесь для просмотра ссылки.

Пожалуйста, авторизуйтесь для просмотра ссылки.
credits: llama
Можно было бы цепи Маркова прикрутить тогда уже, если это генератор слов ( предложений? )
 
Можно было бы цепи Маркова прикрутить тогда уже, если это генератор слов ( предложений? )
ай донт спик инглиш просто написал как мог ,а уебищный яндекс переводчик помогал
 
Не знаю зачем но я это написал, не тестировал, но на godbolt работает
Bad code!:
Expand Collapse Copy
#include <fstream>
#include <iostream>
#include <random>
#include <vector>

// Define the file name
constexpr std::string_view svFileName { "Words.txt" };

// Check if the file name is empty (compile time)
static_assert( !svFileName.empty( ), "The file name cannot be empty!" );

template < class TValueType = std::uint32_t >
    requires std::integral< TValueType >
[[nodiscard]] constexpr TValueType GetRandomNumber( const TValueType &rMin, const TValueType &rMax ) noexcept {
    // Create a random engine
    std::mt19937_64 mtEngine { std::random_device { }( ) };

    // Create a uniform distribution between rMin and rMax
    std::uniform_int_distribution< TValueType > uidDistribution { rMin, rMax };

    // Return the random number
    return uidDistribution( mtEngine );
}

int main( ) try {
    // Open the file for reading
    std::ifstream ifsFile { svFileName.data( ), std::ios::in };

    // Check if the file is open
    if ( !ifsFile.is_open( ) )
        throw std::runtime_error { "The file cannot be opened!" };

    // Create a vector of words
    std::vector< std::string_view > vecWords { };

    // Read the words from the file
    for ( std::string strWord { }; std::getline( ifsFile, strWord ); )
        vecWords.emplace_back( strWord.data( ) );

    // Check if the vector is empty
    if ( vecWords.empty( ) )
        throw std::runtime_error { "The vector cannot be empty!" };

    // Get a random number
    const auto iRandomNumber { GetRandomNumber< std::uint32_t >( 0, vecWords.size( ) - 1 ) };

    // Print the random word
    std::cout << "Random word: " << vecWords.at( iRandomNumber ) << "\n";

    // Wait for the user to press a key (so that stop console)
    std::cin.get( );

    // Return false to indicate that the program ended successfully
    return 0;
} catch ( const std::exception &rException ) {
    // Print the exception message
    std::cout << "Exception: " << rException.what( ) << "\n";

    // Wait for the user to press a key (so that stop console)
    std::cin.get( );

    // Return true to indicate that the program ended with an error
    return 1;
}
C++:
Expand Collapse Copy
#include <fstream>
#include <iostream>
#include <random>
#include <vector>
#include <string>

template < typename _int_t >
// random_int, функция работает лишь для целых чисел
// нет ограничения, uniform_int_distribution и так имеет проверку на тип
constexpr _int_t random_int( const _int_t& min, const _int_t& max ) {
    // default_random_engine потому что не требуется определенная функция
    static std::default_random_engine s_random_engine{ std::random_device{}( ) };

    return std::uniform_int_distribution< _int_t >{ min, max }( s_random_engine );
}

int main( ) {
    std::ifstream file{ "words.txt", std::ios::in };
    if ( !file )
        // эксепшн здесь - название константа, было бы иначе - printf, goto place_path_input
        throw std::runtime_error( "file loading error, try again\n" );

    std::vector< std::string > words{};
    for ( std::string word{}; std::getline( file, word ); )
        words.emplace_back( word );

    if ( words.empty( ) )
        return std::printf( "the file doesn't contain words\n" );

    std::printf( "%s", words[ random_int< std::size_t >( 0, words.size( ) - 1 ) ].data( ) );

    return std::cin.get( );
}

?
 
Назад
Сверху Снизу