Randomize a string in C

前端 未结 3 1030
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 10:59

I\'m trying to generate random permutations of an 80-character fixed string in C. Much to my dismay, the system I\'m working on lacks strfry(). What\'s the best way for me to

3条回答
  •  伪装坚强ぢ
    2021-02-06 11:31

    create a 80-line array, put a character and a random number into each line of the array, then sort the array on the random numbers.

    Rebuild string from sorted array.

提交回复
热议问题