#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;
int a
= 'a' + rand() % 26; 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) {
for (int i = 0; i < 6; i++)
}
int main() {
srand((unsigned)time(NULL
)); //乱数を生成する時のおまじない int i, n;
Monster *monsters;
// ユーザーからモンスターの数を入力
// ここでモンスターの配列を動的に確保する
monsters
= (Monster
*)malloc(n
* sizeof(Monster
));
// メモリ確保のエラーチェック
if (monsters == NULL) {
return 0;
}
// n体のモンスターを生成して表示
for (i = 0; i < n; i++) {
monsters[i] = creMonster();
priMonster(monsters[i]);
}
// 動的に確保したメモリを解放
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4gLy/kubHmlbDjga7nlJ/miJDjga7jgZ/jgoEKCnR5cGVkZWYgc3RydWN0IHsKICAgIGNoYXIgbmFbNjRdOwogICAgaW50IHN0dHNbNl07Cn0gTW9uc3RlcjsKCk1vbnN0ZXIgY3JlTW9uc3RlcigpewogICAgaW50IGksIGs7CiAgICBNb25zdGVyIHRtcDsKICAgIGsgPSByYW5kKCkgJSA4ICsgNDsKICAgIGludCBhID0gJ2EnICsgcmFuZCgpICUgMjY7CiAgICBmb3IgKGkgPSAwOyBpIDwgazsgaSsrKSB0bXAubmFbaV0gPSAnYScgKyByYW5kKCkgJSAyNjsKICAgIHRtcC5uYVtrXSA9ICdcMCc7CiAgICBmb3IgKGkgPSAwOyBpIDwgNjsgaSsrKSB0bXAuc3R0c1tpXSA9IHJhbmQoKSAlIDI1NSArIDE7CiAgICByZXR1cm4gdG1wOwp9Cgp2b2lkIHByaU1vbnN0ZXIoTW9uc3RlciBtKSB7CiAgICBwcmludGYoIiUxMnMgIDogIiwgbS5uYSk7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IDY7IGkrKykKICAgICAgICBwcmludGYoIiUzZCAiLCBtLnN0dHNbaV0pOwogICAgcHJpbnRmKCJcbiIpOwp9CgppbnQgbWFpbigpIHsKICAgIHNyYW5kKCh1bnNpZ25lZCl0aW1lKE5VTEwpKTsgLy/kubHmlbDjgpLnlJ/miJDjgZnjgovmmYLjga7jgYrjgb7jgZjjgarjgYQKICAgIGludCBpLCBuOwogICAgTW9uc3RlciAqbW9uc3RlcnM7CgogICAgLy8g44Om44O844K244O844GL44KJ44Oi44Oz44K544K/44O844Gu5pWw44KS5YWl5YqbCiAgICBzY2FuZigiJWQiLCAmbik7CgogICAgLy8g44GT44GT44Gn44Oi44Oz44K544K/44O844Gu6YWN5YiX44KS5YuV55qE44Gr56K65L+d44GZ44KLCiAgICBtb25zdGVycyA9IChNb25zdGVyICopbWFsbG9jKG4gKiBzaXplb2YoTW9uc3RlcikpOwoKICAgIC8vIOODoeODouODqueiuuS/neOBruOCqOODqeODvOODgeOCp+ODg+OCrwogICAgaWYgKG1vbnN0ZXJzID09IE5VTEwpIHsKICAgICAgICBwcmludGYoIkVSUk9SXG4iKTsKICAgICAgICByZXR1cm4gMDsKICAgIH0KCiAgICAvLyBu5L2T44Gu44Oi44Oz44K544K/44O844KS55Sf5oiQ44GX44Gm6KGo56S6CiAgICBmb3IgKGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgbW9uc3RlcnNbaV0gPSBjcmVNb25zdGVyKCk7CiAgICAgICAgcHJpbnRmKCIlMDNkICAiLCBpICsgMSk7CiAgICAgICAgcHJpTW9uc3Rlcihtb25zdGVyc1tpXSk7CiAgICB9CgogICAgLy8g5YuV55qE44Gr56K65L+d44GX44Gf44Oh44Oi44Oq44KS6Kej5pS+CiAgICBmcmVlKG1vbnN0ZXJzKTsKCiAgICByZXR1cm4gMDsKfQo=