#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct {
char na[64];
int stts[6];
} Monster;
Monster creMonster(){
int i,k;
Monster tmp;
for(i
=0;i
<k
;i
++) tmp.
na[i
] = 'a' + rand()%26; tmp.na[k] = '\0';
for(i
=0;i
<6;i
++) tmp.
stts[i
] = rand()%255+1; return tmp;
}
void priMonster(Monster m){
const char* status_names[] = {
"攻撃力", "防御力", "素早さ", "体力", "知力", "幸運"
};
printf("名前:%12s \nステータス : \n", m.
na);
for(int i = 0; i < 6; i++) {
printf("%s:%3d\n", status_names
[i
], m.
stts[i
]); }
}
int main(){
int i, n;
printf("生成するモンスターの数を入力してください\n");
printf("生成するモンスターの数は %d です。\n", n
);
Monster *monsters;
monsters
= (Monster
*)malloc(sizeof(Monster
)*n
);
if(monsters == NULL){
return 0;
}
for(i = 0; i < n; i++){
monsters[i] = creMonster();
priMonster(monsters[i]);
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4gCgp0eXBlZGVmIHN0cnVjdCB7CiAgICBjaGFyIG5hWzY0XTsKICAgIGludCBzdHRzWzZdOwp9IE1vbnN0ZXI7CgpNb25zdGVyIGNyZU1vbnN0ZXIoKXsKICAgIGludCBpLGs7CiAgICBNb25zdGVyIHRtcDsKICAgIGsgPSByYW5kKCklOCs0OwogICAgaW50IGEgPSAnYScgKyByYW5kKCklMjY7CiAgICBmb3IoaT0wO2k8aztpKyspIHRtcC5uYVtpXSA9ICdhJyArIHJhbmQoKSUyNjsKICAgIHRtcC5uYVtrXSA9ICdcMCc7CiAgICBmb3IoaT0wO2k8NjtpKyspIHRtcC5zdHRzW2ldID0gcmFuZCgpJTI1NSsxOwogICAgcmV0dXJuIHRtcDsKfQoKdm9pZCBwcmlNb25zdGVyKE1vbnN0ZXIgbSl7CiAgICBjb25zdCBjaGFyKiBzdGF0dXNfbmFtZXNbXSA9IHsKICAgICAgICAi5pS75pKD5YqbIiwgIumYsuW+oeWKmyIsICLntKDml6njgZUiLCAi5L2T5YqbIiwgIuefpeWKmyIsICLlubjpgYsiCiAgICB9OwogICAgCiAgICBwcmludGYoIuWQjeWJje+8miUxMnMgXG7jgrnjg4bjg7zjgr/jgrkgOiBcbiIsIG0ubmEpOwogICAgCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgNjsgaSsrKSB7CiAgICAgICAgcHJpbnRmKCIlc++8miUzZFxuIiwgc3RhdHVzX25hbWVzW2ldLCBtLnN0dHNbaV0pOwogICAgfQp9CgppbnQgbWFpbigpewogICAgc3JhbmQoKHVuc2lnbmVkKXRpbWUoTlVMTCkpOyAKICAgIGludCBpLCBuOwogICAgcHJpbnRmKCLnlJ/miJDjgZnjgovjg6Ljg7Pjgrnjgr/jg7zjga7mlbDjgpLlhaXlipvjgZfjgabjgY/jgaDjgZXjgYRcbiIpOwogICAgc2NhbmYoIiVkIiwgJm4pOwogICAgCiAgICBwcmludGYoIueUn+aIkOOBmeOCi+ODouODs+OCueOCv+ODvOOBruaVsOOBryAlZCDjgafjgZnjgIJcbiIsIG4pOwogICAgCiAgICBNb25zdGVyICptb25zdGVyczsKICAgIG1vbnN0ZXJzID0gKE1vbnN0ZXIgKiltYWxsb2Moc2l6ZW9mKE1vbnN0ZXIpKm4pOwogICAgCiAgICBpZihtb25zdGVycyA9PSBOVUxMKXsKICAgICAgICBwcmludGYoIkVSUk9SXG4iKTsKICAgICAgICByZXR1cm4gMDsKICAgIH0KICAgIAogICAgZm9yKGkgPSAwOyBpIDwgbjsgaSsrKXsKICAgICAgICBtb25zdGVyc1tpXSA9IGNyZU1vbnN0ZXIoKTsKICAgICAgICBwcmludGYoIiUwM2QgICIsIGkgKyAxKTsKICAgICAgICBwcmlNb25zdGVyKG1vbnN0ZXJzW2ldKTsKICAgIH0KICAgIAogICAgZnJlZShtb25zdGVycyk7CiAgICByZXR1cm4gMDsKfQo=