我想在 1 到 50 个口袋妖怪之间随机选择,但rand
只选择阵列中的第 42 个(Dragonite)。我怎样才能让它变得随机?
#include <stdlib.h>
#include <stdio.h>
int main(){
char sorteio1[50][11] = {"Bulbasaur","Venusaur","Charmander","Charmeleon","Charizard","Pidgey","Pidgeotto","Pidgeot","Pikachu","Raichu","Clefairy","Vulpix","Ninetales","Meowth","Psyduck","Golduck","Mankey","Primeape","Growlithe","Arcanine","Abra","Kadabra","Alakazam","Magnemite","Magneton","Onix","Cubone","Marowak","Staryu","Starmie","MrMime","Jynx","Magikarp","Gyarados","Lapras","Ditto","Eevee","Vaporeon","Porygon","Snorlax","Dragonair","Dragonite","Mewtwo","Mew","Chikorita","Sentret","Furret","Hoothoot","Lanturn","Pichu"};
int i;
i = rand() %50;
printf ("%s\n",sorteio1[i]);
system ("Pause");
return 0;
}