Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,971 questions

51,913 answers

573 users

How to shuffle a string in C++

1 Answer

0 votes
#include <iostream>
#include <algorithm>
#include <chrono>
#include <random>
#include <string>

int main() {
    std::string str = "C++ is a high-level, general-purpose programming language";
    
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    
    // Shuffle the string
    std::shuffle(str.begin(), str.end(), std::default_random_engine(seed));
    
    std::cout << str << std::endl;
}

  
  
/*
run:
  
eg+mesl+-hipigoggn r r,svuenuraglpeopCa-galml a  a heneir
  
*/

 



answered Nov 4, 2024 by avibootz

Related questions

2 answers 147 views
147 views asked Nov 1, 2021 by avibootz
2 answers 175 views
1 answer 153 views
153 views asked Feb 20, 2018 by avibootz
1 answer 145 views
145 views asked Feb 20, 2018 by avibootz
1 answer 145 views
145 views asked Feb 19, 2018 by avibootz
1 answer 148 views
148 views asked Feb 19, 2018 by avibootz
1 answer 58 views
58 views asked Nov 3, 2024 by avibootz
...