#include <iostream> #include <vector> #include <random> #include <string> /** * @brief Generates a 12-word seed phrase. * * This function generates a 12-word seed phrase by randomly selecting words from a predefined word list. * * @return Returns a vector of strings representing the 12-word seed phrase. */ std::vector<std::string> generateSeedPhrase() { // Predefined word list std::vector<std::string> wordList = { "apple", "elephant", "fish", "grape", "horse", "ice cream", "jelly", "kiwi", "lemon", "abandon", "ability", "able", "about", "above", "absent", "absorb", "abstract", "absurd", "abuse", "caught", "moon","only","code","engage","drama","cabin","small","exhibit","carry","young","service", "sleep", "skill", "account", "art","pink","kite","panel","net","fatal","pair","renew","buffalo","stadium", "black","sunset","slide","deposit","detail", "bulk", "sun", "program", "claim", "trigger", "cousin","buzz" , "machine", "fox","open","paper","between","fuel","hunt","equip","hedgehog","mosquito","paddle","camp","raven","pepper","sort","calm", "ridge","actor","sniff","power","ball","model","nerve","wether","spawn","accuse","genuis","forward","episode","ethics","blind","dinner", "gravity","bunker","around", "token", "garage","furnace","toddler","genuine","eye","season","label","motor","obvious","federal","quit","gentle","group", "quote","egg","toy","april","decorate","maze","also","front","joke","news","innocent","equal","build","laundry","lounge", "width","velvet","midnight","loyal","unhappy","betray","salute","gun","mango","fire","giraffe","multiply","fabric","deny","pupil","any","entire","act","tilt","dial", "banana","burger","roast","flower","assult","exite","swap","issue","say","return","bread", "pear", "south","donkey","involve","example","project","snake","chief","wagon","jacket","approve","negative","custom","since","castle", "little","trophy","naive","vintage","wage","differ","crop","faith","vacant","trash","diesel","shed","monster","engine","estate","crouch","child", "way","earn","tree","scorpion","trap", "media","copy","van","mouse","enjoy","queistion","scatter","fortune","empty","warm","better","iron","flame","survey","weasel","spend","zoo","impose","can","peasant","erosion","street","inform","toilet","front","air","law", "chimney","attack","doll","fade","file","gasp","doctor","away","hill","divert","embark","employ","effort","bus","claw","badge","frawn","filter","dumb","bright","arm","dignity","glad","capable","blur","basic","endorse","cannon","bridge","attitude","fringe","ankle","cable","glide","blue", "ecology","blanket","energy","bring","amount","dog","baby","assist","gesture","enrich","diagram","drop","flip","alien","found","conduct","collect","feel","club","acoustic","father","already","clinic","great","coil","garlic","dad","cram", "fish","holiday","cactus","anxiety","essay","dinasour","goose","clump","core","bomb","depth","consider","box","adapt","agent","degree","fun","ask","exchange","cruise","arctic","ceiling","garbage","dizzy","august","eyebrow","exotic","cash", "dismiss","harvest","conect","bless","comfort","asset","couple","despair","excess","arque","cart","artwork","barely","divide","dove","eternal","acquire","hen","chieken","arena","affair","force","armed","glass","caution","curtain","grape","fly","have","extra","because","body","advice", "dry","gaze","hip","dust","heart","crack" }; // Random number generator std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> dis(0, wordList.size() - 1); // Generate the seed phrase std::vector<std::string> seedPhrase; for (int i = 0; i < 12; i++) { int index = dis(gen); seedPhrase.push_back(wordList[index]); } return seedPhrase; } /** * @brief Checks the balance of the seed phrase. * * This function checks the balance of the seed phrase by performing some balance checking logic. * In this example, the function simply prints the seed phrase and a message indicating the balance. * * @param seedPhrase The seed phrase to check the balance of. */ void checkBalance(const std::vector<std::string>& seedPhrase) { // Print the seed phrase std::cout << "Seed Phrase: "; for (const std::string& word : seedPhrase) { std::cout << word << " "; } std::cout << std::endl; // Perform balance checking logic // In this example, we assume the balance is always positive std::cout << "Balance: Positive" << std::endl; } /** * @brief Main entry point of the program. * * Generates a 12-word seed phrase and checks its balance. * * @return Returns 0 to indicate successful execution. */ int main() { // Generate the seed phrase std::vector<std::string> seedPhrase = generateSeedPhrase(); // Check the balance of the seed phrase checkBalance(seedPhrase); return 0; }
Write, Run & Share C++ code online using OneCompiler's C++ online compiler for free. It's one of the robust, feature-rich online compilers for C++ language, running on the latest version 17. Getting started with the OneCompiler's C++ compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C++
and start coding!
OneCompiler's C++ online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout << "Enter name:";
getline (cin, name);
cout << "Hello " << name;
return 0;
}
C++ is a widely used middle-level programming language.
When ever you want to perform a set of operations based on a condition If-Else is used.
if(conditional-expression) {
//code
}
else {
//code
}
You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.
Switch is an alternative to If-Else-If ladder.
switch(conditional-expression){
case value1:
// code
break; // optional
case value2:
// code
break; // optional
......
default:
code to be executed when all the above cases are not matched;
}
For loop is used to iterate a set of statements based on a condition.
for(Initialization; Condition; Increment/decrement){
//code
}
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while (condition) {
// code
}
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
do {
// code
} while (condition);
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.
return_type function_name(parameters);
function_name (parameters)
return_type function_name(parameters) {
// code
}